Reputation: 1588
I got a JSON :
$.ajax({
type: "POST",
url: myUrl,
success: function (result) {
var data = JSON.parse(result);
for (var i = 0; i < data.poles.length; i++) {
....
What i see in debugger is that :
data = "{"poles":[{"id":36,"name":"AUVERGNE"},{"id":44,"name":"Alsace"},{"id":42,"name":"Artois"},....],"poleNumber":48}
But i get a message saying that data.poles is not defined
What do i miss?
Upvotes: 0
Views: 413
Reputation: 329
Is Json ok?
{"poles":[{"id":36,"name":"AUVERGNE"},{"id":44,"name":"Alsace"},{"id":42,"name":"Artois"}],"poleNumber":48}
EDIT:
Ok, if you have this JSON:
data = {"poles":[{"id":36,"name":"AUVERGNE"},{"id":44,"name":"Alsace"},{"id":42,"name":"Artois"}],"poleNumber":48}
you can make data.poles perfectly. delete the first ", you have a wrong json, so you will never parse
"{"poles":[{"id":36,"name":"AUVERGNE"},{"id":44,"name":"Alsace"},{"id":42,"name":"Artois"}],"poleNumber":48}
Upvotes: 1