Good day! My data is in .json format. How, with the help of ajax , could it be displayed in html table?

So prompted to make an output to the console $ (function () {

 var ReqHelper = new Object({ timeout: 120000, postJsonOnServiceAndCallback: function (url, method, params, async, func) { $.ajax({ type: "POST", url: url + method, data: "{ args:'" + JSON.stringify(params) + "'}", timeout: ReqHelper.timeout, contentType: "application/json; charset=utf-8", dataType: "json", async: async, success: function (data) { func(JSON.parse(data.d)); }, error: function (data) { console.log(data); } }); }, getJsonOnServiceAndCallback: function (url, method, params, async, func) { $.ajax({ type: "GET", url: url + method, data: { 'args': JSON.stringify(params) }, timeout: ReqHelper.timeout, async: async, success: function (result) { var xdata = result.querySelector("string").innerHTML; var data = JSON.parse(xdata); func(data); }, error: function (result) { console.log(result); } }); } }); ReqHelper.postJsonOnServiceAndCallback("../csharp/Request4Helper.asmx/", "Helper", {}, true, function (data) { console.log(data); }) }); 
  • And where is the page rendering code? That's where you need to insert an ajax request. - Ella Svetlaya
  • @ Andrei Pivovarov help? - propro17
  • And what exactly is "not working." What error gives? - Ella Svetlaya
  • And where in your HTML code is the sortable that you refer to in the script? - Ella Svetlaya
  • @Ella Svetlaya can give an example? - propro17

1 answer 1

The easiest way to use Jquery.ajax for example

 <script type="text/javascript"> var requestSettings = { url: "...", //урл по которому вы отдаете json type: "POST", //Метод зароса GET/POST/DELETE.. success: function(responce) { //вызовется если ответ успешный }, complete: function(responce) { //вызовется в любом случаее }, error: function (jqXHR, textStatus, errorThrown) { //вызовется в случаее ощибки } } $.ajax(requestSettings); </script> 

http://api.jquery.com/jquery.ajax/

  • I got the data to the console. Now you need to display on the table html. Will you help? - propro17 1:01 pm