Is it posible to take http post response from some java servlet into some variable in java script let's say some string?
When I do http post request servlet returns some xml as a response and I would like to take that xml into some variable so that I can parse it with java script and then use that data.
Does any one has some ideas?
What you can do is in your servlet get the string value for that XML object..
root.toString() or something
"var xmlStr = '"+root.toString()+"'";
something along the lines you need to try..
Thank's for your quick answer.
This is exatcly what I'm trying to do.
I do http post from DHTML page on some URL where my servlet is. My servlet then does what it has to be done and
give back response witch is an String xmlstr containing XML with
I would like to catch that xmlstr in my DHTML page in some
java script variable so that I can parse it in java script or that
I can generate a tree with nodes. I've tried it with loading response into layer but I couldn't get xml in it. Do you now of
a way to catch this xmlstr response into some java script variable on the same DHTML page for witch http post request
Thanks and best regards.
Code above will not pust xml string in a js variable..it will just dump all the data to the page.
you need to do something like this.
out.println("var xmlStr = '"+xmlstr);
The above should do what you are looking for