-1

Possible Duplicate:
How to transfer java array to javaScript array using jsp?

After googling I am still not able to pass array from .jsp file to js file. Can somebody help me out?

In my .jsp file i have an array and I wan to call a function in .js file which accepts this array. How to call this function?

2
  • 1
    Try stackoverflow.com/questions/516565/… Commented May 11, 2011 at 14:39
  • I didn't get anything useful from here. Can somebody post some code for this? Commented May 11, 2011 at 15:37

2 Answers 2

0

By passing an array from .jsp to js file I guess you mean your Javascript script needs to "call" a script return by a JSP file. And that script contains a function that returns an array? If so have you looked at returning JSON from your JSP?

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

Comments

0

For simple arrays, you can convert the array to a comma-delimited string using an implode function, pass the string to javascript, and then use split(str) in Javascript to get an array back. More complicated arrays may cause issues with this.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.