开发者

Pass an array from .jsp file to .js file [duplicate]

This question already has answers here: Closed 11 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜