简体   繁体   中英

How to pass string argument to javascript method

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]

Probably just the quotes around the string literal missing?

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

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]

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM