Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
How to split a json data and how to push the data split using Jquery ?
My Code is as follows:
JavaScript
function getData() {

         var $tbl = $('#tblJobInfo');
         $.ajax({

             url: 'GridScore.aspx/JobDataTest',
             type: 'POST',
             contentType: "application/json; charset=utf-8",
             data: "{}",
             datatype: 'json',
             async: true,

             error: function (XMLHttpRequest, textStatus, errorThrown) {
                 alert("Request: " + XMLHttpRequest.toString() + "\n\nStatus: " + textStatus + "\n\nError: " + errorThrown);
             },
             success: function (data) {
                 debugger;
                 alert("x");

                 var abcStr = data.d;
                 var valSplit = abcStr.split('-');
                 alert(valSplit);

                 $tbl.empty();
                 $tbl.append('<table><tbody><tr><th>Job Title</th><th>Published Date</th><th>Expiry Date</th><th>Job Status</th></tr></tbody></table>');

                 var rows = [];

                 //for(var i = 0; i < data.d.length; i++) {

                 //rows.push(' <table><tbody><tr><td>' + data.d[i].JobTitle + '</td><td>' + data.d[i].PublishedDate + '</td><td>' + data.d.[i].ExpiryDate + '</td><td>' + data.d.[i].JobStatus + '</td></tr></tbody></table>');
                 rows.push(' <table><tbody><tr><td>' + "Asp.Net" + '</td><td>' + "06/11/2014" + '</td><td>' + "06/11/2014" + '</td><td>' + "Approved" + '</td></tr></tbody></table>');
                 alert(rows);
                 //}

                 $tbl.append(rows.join(''));

             }
         });
      }
Posted
Updated 7-Nov-14 1:58am
v2
Comments
DamithSL 7-Nov-14 8:02am    
what you the value you get as "abcStr"?
Thanks7872 7-Nov-14 8:25am    
Nothing clear here. Such question should be posted with sample of the data you receive and what you need out of it.

Without this info, question doesn't make much sense.

1 solution

It is not clear the format of received json data from the question, check below links
Convert JSON array to an HTML table in jQuery[^]
Without doing all these json to html table by coding, you can use JqGrid[^] or Dynatable [^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900