0

How to pass string argument to javascript method

my code

function paginatePage(getPath) {


    alert("from pagenate page");
    alert("home path initial " + getPath);
}

unable to get the alert message

when i called the method

[NSString stringWithFormat:@"paginatePage(%s)",getPath]
4
  • What are you passing through? Commented Apr 27, 2011 at 13:11
  • code seems correct. what are you trying to pass? Commented Apr 27, 2011 at 13:11
  • 2
    There's obviously something extremely important you're not telling us here. From what context are you attempting to call this method? What programming environment are we talking about here? Commented Apr 27, 2011 at 13:11
  • 1
    So we have JavaScript and Objective-C here. What is their connection? What do you want to do? Commented Apr 27, 2011 at 13:13

3 Answers 3

3

Probably just the quotes around the string literal missing?

[NSString stringWithFormat:@"paginatePage('%s')",getPath]
Sign up to request clarification or add additional context in comments.

Comments

1

You possibly need to qualify the string with quotes.

I don't know what that NSString syntax is, but something like:

[NSString stringWithFormat:@"paginatePage('%s')",getPath]

Comments

0

Your error does not come from this, because the code is 100% valid : this is how you pass a string argument to a function.

If you could provide some more code, maybe we could help you.

Also, make sure no other function has the same name, or maybe it's how you called the function?

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.