$post / $each with JQuery

Let's say you want to do a JQuery $post and then use $each to traverse through the result. this exampel show how it can be accomplished.

Example JSON data set generated using Php or other scripting languages :-

{"items":[{"memberID":"1","memberName":"Julia Boris","profileInfo":"jaya jaya"},{"memberID":"1","memberName":"Julia Boris","profileInfo":"michael "},{"memberID":"1","memberName":"Julia Boris","profileInfo":"89898989"}]}

From the browser you can use the following codes to do an AJAX Post. Notice the I purposely pass dummy data to the other end. Somehow it returned text instead of JSON if i do not pass dummy data.

You can do some debugging by displaying return "data". If you can see the content of your data as shown example above, then you might not be returning JSON data type - meaning u cannot manipulate it using $each.

Example below also shows you how u can access individual record.

$.post("getExploreRecent.php", {"name" : "dummy"} , function(data)


$.each(data.items ,function(i,item) {

}, "json");

That's it. Pretty straight forward.


Popular posts from this blog

OpenCover code coverage for .Net Core

ionic2 cordova build android - Unable resolve gradle 2.2.3

Using Custom DLL with IronPython / Scripts