Pass an array from .jsp file to .js file [duplicate]
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?
I开发者_JAVA技巧n 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?
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?
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.
精彩评论