showStatistic.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. var service_base_path = '../jaxrs/statisticshow/';
  2. function getStatistic( name, year, month, date ) {
  3. var query_url = service_base_path + $("#queryUrl").val();
  4. if( name != null && name != undefined && name != "(0)"){
  5. query_url = query_url.replace( "{name}", encodeURIComponent(name) );
  6. }
  7. if( date != null && date != undefined && date != "(0)"){
  8. query_url = query_url.replace( "{date}", encodeURIComponent(date) );
  9. }
  10. if( year != null && year != undefined && year != "(0)"){
  11. query_url = query_url.replace( "{year}", year );
  12. }
  13. if( month != null && month != undefined && month != "(0)"){
  14. query_url = query_url.replace( "{month}", month );
  15. }
  16. alert(query_url);
  17. $.ajax({
  18. type : 'get',
  19. dataType : 'json',
  20. contentType : 'application/json; charset=utf-8',
  21. url : query_url,
  22. xhrFields : {
  23. 'withCredentials' : true
  24. },
  25. crossDomain : true
  26. }).done(function(json) {
  27. $('#result').html( JSON.stringify( json, null, 4) );
  28. }).fail(function(json) {
  29. failure(json);
  30. });
  31. }
  32. function getFilterListForStatistic( last_id, _count ){
  33. var service_url = $("#putUrl").val();
  34. var query_url = service_base_path + "/" + service_url;
  35. if( last_id == null || last_id == undefined ){
  36. last_id="(0)";
  37. }
  38. if( _count == null || _count == undefined ){
  39. _count=20;
  40. }
  41. //根据参数组织URL
  42. query_url = query_url.replace( "{id}",last_id );
  43. query_url = query_url.replace( "{count}",_count );
  44. alert( "PUT:"+query_url );
  45. $.ajax({
  46. type : 'put',
  47. dataType : 'json',
  48. contentType : 'application/json; charset=utf-8',
  49. url : query_url,
  50. xhrFields : {
  51. 'withCredentials' : true
  52. },
  53. data : JSON.stringify($.parseJSON($('#content').val())),
  54. crossDomain : true
  55. }).done(function(json) {
  56. $('#result').html(JSON.stringify(json.data, null, 4));
  57. });
  58. }