southbeach
Programmer
I cannot tell you how many times I've done this ... today, like a couple of other things, I cannot get it to work.
I have the following object
My script looks like this
I've tried changing var jjson=JSON.parse(obj); to var jjson=JSON.parse(obj[0]);
both syntax give me this error
JSON.parse: unexpected character at line 1 column 2 of the JSON data
What gives?
--
SouthBeach
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.
I have the following object
Code:
[
{
"name":"AAA",
"message":"msg 1",
"days":"5",
"cost":"304.40",
"qnumber":"",
"jnumber":"",
"saveit":""
},
{
"name":"BBB",
"message":"msg 2",
"days":"4",
"cost":"285.91",
"qnumber":"20160926",
"jnumber":"333333",
"saveit":""
},
{
"name":"CCC",
"message":"msg 3",
"days":"3",
"cost":"2,355.08",
"qnumber":"4404556211619",
"jnumber":"12345",
"saveit":""
},
{
"name":"DDD",
"message":"msg 4",
"days":"3",
"cost":"525.20",
"qnumber":"201612181538",
"jnumber":"",
"saveit":""
}
]
Code:
var jjson=JSON.parse(obj);
dataObject=obj; var tlist='';
$('#rfqgridROWS').empty();
for(var i = 0; i < jjson.length; i++) {
var data = jjson[i];
tlist+='<tr id="row'+i+'" class="datarow">';
tlist+='<td>'+data.carrierName+'</td>';
tlist+='<td>'+data.message+'</td>';
tlist+='<td>'+data.days+'</td>';
tlist+='<td>'+data.cost+'</td>';
tlist+='<td>'+data.qnumber+'</td>';
tlist+='<td>'+data.jnumber+'</td>';
tlist+='<td style="font-size: 16px; text-align: center;"><li class="fa fa-save"></li></td>';
tlist+='</tr>';
}
$('#rfqgridROWS').html(tlist);
I've tried changing var jjson=JSON.parse(obj); to var jjson=JSON.parse(obj[0]);
both syntax give me this error
JSON.parse: unexpected character at line 1 column 2 of the JSON data
What gives?
--
SouthBeach
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.