Wednesday, March 21, 2012

How can I send xml data to server

I′m trying to send some xml data to a server and I always get Internal Server Error. I really don′t know why, because if I do the same thing, but instead of xml data I send some string, it′s working fine.

Here′s is sample code of what I′m trying to do:

createXMLHttpRequest();
var xml = createXMLData();

var url = "MyPage.aspx";
xmlHttp.open("POST", url, true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

xmlHttp.onreadystatechange = processStateChange;
xmlHttp.send(xml);

If I change thexmlHttp.send(xml); to for examplexmlHttp.send("something"); it′s working.

the xml data looks like: <AccountData><Email>something</Email><Login>something</Login></AccountData>

Can anyone help me with this please?

what is the createXMLData returning. An xml dom object or a string of xml. If it is a dom object you will first need to convert it to a string and then send it

No comments:

Post a Comment