I am using Jquery and AJAX to call a web method in my C# code behind, which runs a stored procedure and then sends the data back as a string. This is all working perfectly.
When I have my values back and I try make an array out of them so I can select only certain objects out of the array, everything falls apart. I have made a quick FIDDLE of the problem I am having.
I receive a string like this from my Stored Procedure: 12, 1288, 1800, 3088, 26288
But when I try get the "12" only, I either receive the whole string or just the "1" from the 12.
I have tried everything from makeArray, stringify, split, replacing then splitting, making an array variable and push() into it... nothing seems to work.
Below is some of my scrap code which I have been commenting out as I try and I've also added an image of the code behind while stepping through:
$.ajax({
type: "POST",
url: "LeadGraphGeneration.aspx/GetData",
contentType: "application/json; charset=utf-8",
data: strRequest,
dataType: "json",
success: function (msg) {
var returned = (msg.d);
// var returned = new Array();
// $(msg.d).each(function () {
// returned.push(this);
// });
ret1 = returned[1];
// var returnedd = JSON.stringify(msg.d);
// var returned = $.makeArray(returnedd);
// var ret1 = returned[0];
// var ret2 = returned[1];
// var ret3 = returned[2];
// var ret4 = returned[3];
// var ret5 = returned[4];
//data1 = dataArray[0];
$("#PaymentPeriod").text(ret1);
// $("#TotalInterest").text(ret2);
// $("#TotalFees").text(ret3);
// $("#TotalCost").text(ret4);
// $("#TotalPayment").text(ret5);
(Right click, open in new tab for full size)
I'm hoping you could help me figure out why I can't select individual objects from the array which I am struggling to build.
Please let me know if you need any more info.
var rett = $.parseJSON("["+returnedd+"]");