Answer the question
In order to leave comments, you need to log in
JSON Object or not Object. Why?
We have a sign
<table id="example">
<tbody>
<tr id="rowID"
data-all='{"id": 1, "name": "name1"}'>
<td data-id="01">Tiger Nixon</td>
<td data-id="02">System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$320,800</td>
</tr>
</tbody>
</table>
$("#example td").bind('click', function(){
var all = $('#rowID').data('all');
alert(all);
});
data-all='{"id": 1, "name": "name1"}'
data-all='{"id": 01, "name": "name1"}'
Answer the question
In order to leave comments, you need to log in
Most likely jQuery does this by catching the exception in JSON.parse. 01 is not a valid number and will break JSON.parse, which means that when catching an exception, jQuery will assume that this is not JSON and will return just a string.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question