entity_script.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. function data_get_script( ) {
  2. var service_url = $("#service_url").val();
  3. var query_url = '../jaxrs/script/' + service_url;
  4. //获取用户所填写的参数
  5. var id = $("#id").val();
  6. var appId = $("#appId").val();
  7. var name = $("#name").val();
  8. var last_id = $("#last_id").val();
  9. var count = $("#count").val();
  10. //根据参数组织URL
  11. if( "{id}" == service_url ){
  12. query_url = query_url.replace( "{id}",id );
  13. if( id == null || id == "" || id == undefined){
  14. alert("请填写ID");return false;
  15. }
  16. }else if( "list/app/{appId}" == service_url ){
  17. query_url = query_url.replace( "{appId}",appId );
  18. if( appId == null || appId == "" || appId == undefined){
  19. alert("请填写appId");return false;
  20. }
  21. }else if( "list/app/{appId}/name/{name}" == service_url ){
  22. query_url = query_url.replace( "{appId}",appId );
  23. query_url = query_url.replace( "{name}",name );
  24. if( appId == null || appId == "" || appId == undefined){
  25. alert("请填写appId");return false;
  26. }
  27. if( name == null || name == "" || name == undefined){
  28. alert("请填写name");return false;
  29. }
  30. }else if( "list/{id}/next/{count}" == service_url ){
  31. query_url = query_url.replace( "{id}",last_id );
  32. query_url = query_url.replace( "{count}",count );
  33. if( last_id == null || last_id == "" || last_id == undefined){
  34. alert("请填写last_id");return false;
  35. }
  36. if( count == null || count == "" || count == undefined){
  37. alert("请填写count");return false;
  38. }
  39. }else if( "list/{id}/prev/{count}" == service_url ){
  40. query_url = query_url.replace( "{id}",last_id );
  41. query_url = query_url.replace( "{count}",count );
  42. if( last_id == null || last_id == "" || last_id == undefined){
  43. alert("请填写last_id");return false;
  44. }
  45. if( count == null || count == "" || count == undefined){
  46. alert("请填写count");return false;
  47. }
  48. }
  49. alert(query_url);
  50. $.ajax({
  51. type : 'get',
  52. dataType : 'json',
  53. contentType : 'application/json; charset=utf-8',
  54. url : query_url,
  55. xhrFields : {
  56. 'withCredentials' : true
  57. },
  58. crossDomain : true
  59. }).done(function(json) {
  60. $('#result').html( JSON.stringify( json, null, 4) );
  61. }).fail(function(json) {
  62. failure(json);
  63. });
  64. }
  65. function data_put_script( id ) {
  66. if( id == null || id == undefined || id == "" ){
  67. alert("请输入ID");
  68. return false;
  69. }
  70. $.ajax({
  71. type : 'put',
  72. dataType : 'json',
  73. contentType : 'application/json; charset=utf-8',
  74. url : '../jaxrs/script/' + id,
  75. xhrFields : {
  76. 'withCredentials' : true
  77. },
  78. data : JSON.stringify($.parseJSON($('#content').val())),
  79. crossDomain : true
  80. }).done(function(json) {
  81. $('#result').html(JSON.stringify(json.data, null, 4));
  82. });
  83. }
  84. function data_post_script( id ) {
  85. $.ajax({
  86. type : 'post',
  87. dataType : 'json',
  88. contentType : 'application/json; charset=utf-8',
  89. url : '../jaxrs/script' ,
  90. xhrFields : {
  91. 'withCredentials' : true
  92. },
  93. data : JSON.stringify($.parseJSON($('#content').val())),
  94. crossDomain : true
  95. }).done(function(json) {
  96. $('#result').html(JSON.stringify(json.data, null, 4));
  97. });
  98. }
  99. function data_delete_script( id ) {
  100. if( id == null || id == undefined || id == "" ){
  101. alert("请输入ID");
  102. return false;
  103. }
  104. $.ajax({
  105. type : 'delete',
  106. dataType : 'json',
  107. contentType : 'application/json; charset=utf-8',
  108. url : '../jaxrs/script/' + id ,
  109. xhrFields : {
  110. 'withCredentials' : true
  111. },
  112. crossDomain : true
  113. }).done(function(json) {
  114. $('#result').html(JSON.stringify(json.data, null, 4));
  115. });
  116. }