Click here to Skip to main content
15,887,350 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How to split the json values from server side via asp.net and jquery?
The json values I am getting are as follows:
[{"JobTitle":"Asp.Net","Name": Alex"},{"JobTitle":"PHP","Name": Arun"}]

I want to split the above and obtain the datas as Asp.Net,Alex,PHP,Arun.


function getData() {

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

url: 'GridScore.aspx/JobData',
type: 'POST',
contentType: "application/json; charset=utf-8",
data: "{}",
datatype: 'json',
async: true,
cache: false,
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert("Request: " + XMLHttpRequest.toString() + "\n\nStatus: " + textStatus + "\n\nError: " + errorThrown);
},
success: function (data) {
debugger;
//alert(data.d);
//alert(data.length);
$tbl.empty();
$tbl.append('
Job TitlePublished DateExpiry DateJob Status
');

var rows = [];

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

//rows.push('
' + data[i].JobTitle + '' + data[i].PublishedDate + '' + data[i].ExpiryDate + '' + data[i].JobStatus + '
');
rows.push('
' + "Asp.Net" + '' + "06/11/2014" + '' + "06/11/2014" + '' + "Approved" + '
');
//alert(rows);
// }
$tbl.append(rows.join(''));

}
});
Posted
Updated 6-Nov-14 22:33pm
v2
Comments
Pravuprasad 7-Nov-14 4:38am    
This is the javascript code. But where is your Asp.net code.Show that what you have done.

1 solution

try this..

C#
var obj = $.parseJSON('[{"Name": "Sajid","JobTitle": "Asp.Net"},{"Name": "Venkata","JobTitle": "SSE"}]');
for(var i=0;i<obj.length;i++)
{
alert(obj[i]['JobTitle']);
    alert(obj[i]['Name']);
}
 
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