I believe the problem is this line:
$.each(postsJSON, postsJSON1, function(i, post, post1) {
The generic iterator $.each() function accepts only two parameters, the second of which should be a function. Similarly, the callback function you provide must take two parameters.
What is your intention if you order two objects at the same time? If you can describe your data structures and explain what you want to do, I could make some suggestions. (Show your JSON ...)
UPDATE: OK, based on updating the question, both postsJSON and postsJSON1 are arrays. Considering how you tried to use both from within the same function, it seems that the elements in the arrays have a one-to-one relationship, that is, postsJSON[0] refers to postsJSON1[0] , postsJSON[1] refers to postsJSON1[1] postsJSON[2] refers to postsJSON1[2] , etc. etc.
If so, the smallest possible change to your existing code to make it work would be as follows:
var postHandler = function(postsJSON, postsJSON1) { $.each(postsJSON, function(i, post) { var post1 = postsJSON1[i];
That is, continue to use $.each() , but noting that it can only iterate over one array at a time, using the provided index i to iterate over another array in parallel, setting it manually as the first line of the function.
Or perhaps a more obvious way to do this with the traditional for loop:
var postHandler = function(postsJSON, postsJSON1) { var i, post, post1; for (i = 0; i < postsJSON.length; i++) { post = postsJSON[i]; post1 = postsJSON1[i];
In any case, both arrays are processed in parallel. Obviously, this assumes that the arrays are the same length and that the elements of any index number will be the elements that you want to associate with each other, as mentioned above - if not, then you will need to provide more detailed information about how the arrays are connected.