main_entity.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. function data_query() {
  2. var html = template( 'data_query_template', request_config );
  3. $('#content').html(html);
  4. $('#result').html('');
  5. $('#get', '#content').click(function() {
  6. data_get($('#id').val(), $('#type').val());
  7. });
  8. $('#put', '#content').click(function() {
  9. data_put($('#id').val(), $('#type').val());
  10. });
  11. $('#post', '#content').click(function() {
  12. data_post($('#id').val(), $('#type').val());
  13. });
  14. $('#uuid', '#content').click(function() {
  15. get_uuid();
  16. });
  17. }
  18. function get_uuid( ) {
  19. $('#data', '#content').val('');
  20. $.ajax({
  21. type : 'get',
  22. dataType : 'json',
  23. url : '../jaxrs/uuid/random',
  24. xhrFields : {
  25. 'withCredentials' : true
  26. },
  27. crossDomain : true
  28. }).done(function(json) {
  29. $('#result').html(JSON.stringify( json, null, 4));
  30. });
  31. }
  32. function data_get(id, type) {
  33. var query_url = '../jaxrs/' + type + '/' + id;
  34. if( id == null || id == undefined || id == "" ){
  35. query_url = '../jaxrs/' + type + '/list/all';
  36. }
  37. alert(query_url);
  38. $('#data', '#content').val('');
  39. $.ajax({
  40. type : 'get',
  41. dataType : 'json',
  42. contentType : 'application/json; charset=utf-8',
  43. url : query_url,
  44. xhrFields : {
  45. 'withCredentials' : true
  46. },
  47. crossDomain : true
  48. }).done(function(json) {
  49. $('#result').html(JSON.stringify( json, null, 4));
  50. }).fail(function(json) {
  51. failure(json);
  52. });
  53. }
  54. function data_put( id, type ) {
  55. $.ajax({
  56. type : 'put',
  57. dataType : 'json',
  58. contentType : 'application/json; charset=utf-8',
  59. url : '../jaxrs/' + type + '/' + id,
  60. xhrFields : {
  61. 'withCredentials' : true
  62. },
  63. data : JSON.stringify($.parseJSON($('#data', '#content').val())),
  64. crossDomain : true
  65. }).done(function(json) {
  66. $('#result').html(JSON.stringify(json.data, null, 4));
  67. });
  68. }
  69. function data_post( id, type ) {
  70. $.ajax({
  71. type : 'post',
  72. dataType : 'json',
  73. contentType : 'application/json; charset=utf-8',
  74. url : '../jaxrs/' + type ,
  75. xhrFields : {
  76. 'withCredentials' : true
  77. },
  78. data : JSON.stringify($.parseJSON($('#data', '#content').val())),
  79. crossDomain : true
  80. }).done(function(json) {
  81. $('#result').html(JSON.stringify(json.data, null, 4));
  82. });
  83. }