views:

440

answers:

2

I'm looking to write some Javascript which will make an Ajax PUT or POST request to an HTTP server. I'm assuming that the information which gets passed as the argument to request.send needs to be in XML format. Could somebody shoe me an example of how to create this XML and pass it to request.send([Entity-body]) as the entity-body.

Thanks!

+1  A: 

The "xml" in XmlHttpRequest is entirely superfluous; there's never been a requirement that the request or the response is in xml format.

In fact, it's just as common to send JSON (JavaScript object notation) instead of xml.

So, don't use xml unless you want to. Just send any string you want.

dmazzoni
+1  A: 

You don't have to send xml, you can send any arbitrary string.

an example for http post would be

request.send("id=1&somattribute=value&etc=etcetc");

where you have name value pairs

name=value

separated by &

Charles Ma
if I wanted to send XML would I create it as a string like you did or would I need to make it some other way?
Kelly Stevens
You can create it as a string and just send the string
Charles Ma