javascript - ^How to parse multiple JSON arrays received from server? -


here json data received server:

[      {"name":"a"},       {"name":"b"},      {"name":"c"},      {"name":null} ] [      {"name":null},      {"name":"d"},      {"name":null} ] [       {...},      {...} ] 

how parse using using jquery in ajax success attribute?

here ajax code:

$.ajax({         url: '#.php',     type: 'post',     async: false,     data: {},     datatype: 'json',     success: function(data){         var str = json.stringify(data);         var obj = json.parse(str);          for(var i=0; i< data.length;i++)         {             alert(data[i].name);         }     },     complete: function(xhr,status){         alert(status);     },     error: function(xhr){         alert("an error occured: " + xhr.status + " " + xhr.statustext );         alert("an error occured. please try again");     } }) 

this code not working , giving parser error on complete. want display names received. please help.

your data received server not valid json, if was, :

[     [{         "name": "a"     }, {         "name": "b"     }, {         "name": "c"     }, {         "name": null     }],     [{         "name": null     }, {         "name": "d"     }, {         "name": null     }] ] 

that easier parse:

[{     "name": "a" }, {     "name": "b" }, {     "name": "c" }, {     "name": null }, {     "name": null }, {     "name": "d" }, {     "name": null }] 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -