Click to See Complete Forum and Search --> : xmlhttpreq post method - help please


soldierdog
05-10-2005, 12:42 PM
It may be a silly question but I just don't know how to get xmlhttpreq to POST information.

I can easily use get. So do I need to create a form and if so, what needs to be included in it and also how does xmlhttpreq know what form to submit if there are several etc. etc. A working example of POST with xmlhttpreq with a form or whatever would be very valuable to me right now because I just can't find one on the web. They are all GET examples.

--Leander

shimon
05-11-2005, 06:47 AM
It's not a silly question :) but hte answer is probably simpler than you imagine.You'll just need to change 'GET' to 'POST' when you open the connection.


req = new XMLHttpRequest();
req.open("POST", url);


To send variables, you can just build a query string and send it like so:


req.send('foo=bar&var=33');

soldierdog
05-11-2005, 12:39 PM
Wow, that was easy.

I suspected that it might be either 1, super easy which is why there were no examples or two super hard which is rarely the case.

Regadless thank you very much,


Leander

Dave_Dixon
06-20-2005, 08:56 AM
is there an equally simple way to get the data posted using the server side code? I'm posting some XML to an .aspx page using VB .NET. How would i go about posting this and then retrieving the post on the server side to save into a database?