0

I have a small problem with a javascript variable that I cannot figure out. I am trying to pass a variable to a Jquery function parameter but it doesn't work.

Original code:

$(".bt-fs-dialog").fSelector({
  max: 25,
  excludeIds: [],
  getStoredFriends: [],
  closeOverlayClick: true,

});

Now I want to pass values to the getStoredFriends field. The documentation says it should be added like this: getStoredFriends: [12345678,5484545],

So this is what I do:

var testresponse = "193102451,731800273";

$(".bt-fs-dialog").fSelector({
  max: 25,
  excludeIds: [],
  getStoredFriends: testresponse,
  closeOverlayClick: true,

});

This doesn't work. No values are added to the function. I also tried to pass the values as an array:

var testresponse = new Array();
testresponse[0] = "193102451";
testresponse[1] = "731800273";

$(".bt-fs-dialog").fSelector({
  max: 25,
  excludeIds: [],
  getStoredFriends: testreponse,
  closeOverlayClick: true,

});

This also doesn't work. Can anyone explain how I can pass the values to this function? Thanks in advance!

3
  • What is that fSelector ? Commented Feb 5, 2013 at 11:37
  • For reference, OP seems to be using Facebook Friend Selector. Commented Feb 5, 2013 at 11:39
  • Yes, sorry I forgot to mention. I am using Facebook Friend Selector. Commented Feb 5, 2013 at 11:59

2 Answers 2

2

[12345678,5484545] is an array of numbers, so that's probably what expects this function.

Try with

var testresponse = []; // better than new Array()
testresponse.push(193102451); // using push you don't have to specify the index
testresponse.push(731800273);
Sign up to request clarification or add additional context in comments.

1 Comment

Or just var testresponse = [193102451, 731800273];. You don't actually need a variable either, you can throw that array literal straight in the object literal.
0

Try this var testresponse = [193102451,731800273]

This should work

testresponse[0] will give 193102451 and testresponse[1] will give 731800273

Comments

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.