Difficulty in displaying Json objects in arrays
When the page is loading for the first time, it`s working fine and displaying the data.
When I am doing a search the data returned are"[{"ID":358,"Name":"Test,"Client":{"ID":160,"Name":"Client1"},"HasUsers":false}]", but i`m having the message error:
Client is not defined
I am having the following piece of code:
In my View
<script id="myTemplate" type="text/x-jquery-tmpl">
<tr>
<td>${Client.Name}</td>
<td>${Name}</td>
</tr>
</script>
code to bind
success: function (data) {
$("#myTemplate").tmpl(data).appendTo("#dataBody&开发者_开发百科quot;);
},
What is wrong with the above?
Your JSON doesn't not seem right. it should be
[{"ID":358,"Name":"Test","Client":{"ID":160,"Name":"Client1"},"HasUsers":false}]
instead of
[{"ID":358,"Name":"Test,"Client":{"ID":160,"Name":"Client1"},"HasUsers":false}]
"Test,
should be "Test",
which is what is messing with Client, probably.
精彩评论