Frankely Diaz wrote:How i write in a servlet response an javascript array?
Hi,
Rather than doing just the array, creat a JSON object
string containing an array, like that
{arrwhatever: ["first val", "second val", "third val"]}
- Be careful to ensure that the object can be parsed by the client. How you do it: load on the client the string in a variable, let's call it alfa, and then say
var beta = eval ('(' + alfa + ')') and you got the Javascript object, and beta.arrwhatever would contain your array
- This is typical for Ajax, this is what you try to do, right?
- This construct gives you flexibility. Maybe the servlet call crashes, in this case instead of arrwhatever you load another attribute called error in which you pass whatever error happened.
Regards,
Daniel