0
var tmpANArray = [];
for (var i in associatedPpl) {
    tmpANArray.push(associatedPpl[i]);
}
alert('about to call toJSON on AssociatedPpl');
alert(tmpANArray);
// the next line fails because $.toJSON is getting fed a function
var jsonEncodedAssociatedPpl = $.toJSON(tmpANArray);

What part of JavaScript/jQuery am I missing?

UPDATE The JS JSON lib was jquery.json-1.3.min.js

3
  • What are you using for the $.toJSON - that isn't a part of jquery. Are you using a plugin? Commented Jun 30, 2010 at 22:03
  • He's using code.google.com/p/jquery-json probably. Commented Jun 30, 2010 at 22:05
  • What does associatedPpl looks like? Commented Jun 30, 2010 at 22:13

2 Answers 2

1

You have your for cycle wrong, it is actually a foreach so your i variable should not be used to index the array, because its the value itself, change it to:

var tmpANArray = [];
for (var i in associatedPpl) {
    tmpANArray.push(i);
}

Or why not use the associatedPpl array directly?

Sign up to request clarification or add additional context in comments.

1 Comment

weird that I missed that. Wondering what about associatedPpl[i] returns a function though.
0

there's no toJSON natively in Jquery. Do you mean to use getJSON()? Are you involving a function that you haven't provided information about?

getJSON documentation: http://api.jquery.com/jQuery.getJSON/

1 Comment

He didnt mention it, but I think he's using code.google.com/p/jquery-json

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.