Note that there are some explanatory texts on larger screens.

plurals
  1. POlooping within list using jQuery
    primarykey
    data
    text
    <p>By help <a href="https://stackoverflow.com/questions/17754414/handling-json-data-using-jquery-sent-by-using-newtonsoft-json">my last question</a> got solved but still stuck.. </p> <p><a href="https://stackoverflow.com/questions/6524920/looping-through-json-array-in-a-jquery-list">After trying this</a> I got an error on console log.. </p> <pre><code>Error: Syntax error, unrecognized expression: [ { "id": 1, "name": "Bhavik", "phone": 9601109585 }, { "id": 2, "name": "Xyz", "phone": 1234567890 }, { "id": 3, "name": "Abc", "phone": 9876543210 } ] [Break On This Error] throw new Error( "Syntax error, unrecognized expression: " + msg ); </code></pre> <p><strong>jQuery code:</strong> </p> <pre><code>var list = { "Persons": data.d }; $(list.Persons).each(function (index) { alert( this.id + "\n" + this.name + "\n" + this.phone); }); </code></pre> <p><strong>JSON array:</strong> </p> <pre><code>[ { "id": 1, "name": "Bhavik", "phone": 9601109585 }, { "id": 2, "name": "Xyz", "phone": 1234567890 }, { "id": 3, "name": "Abc", "phone": 9876543210 } ] </code></pre> <p>I want to loop through the list.. Any ideas..</p> <p><strong>EDIT</strong> After @Vucko's suggestion I tried replacing <code>data.d</code> by the the JSON array itself and to my surprise it worked <a href="http://jsfiddle.net/uR7m4/1/" rel="nofollow noreferrer">JSFiddle</a>.. Any reason and solution for it..</p> <p><strong>Solved</strong> changed <code>var list = { "Persons": $.parseJSON(data.d)};</code>.. JSON response is not enough I guess.. We need to parse it also..</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload