I am using dojo.request.xhr to make a post reqeust to geoserver. But the problem is when i'm using XMLHttpRequest to make the post request , it is working fine on the other hand when i'm using dojo.reqeust.xhr for the same thing its giving the following error.
*
org.xmlpull.v1.XmlPullParserException: only whitespace content allowed before start tag and not i (position: START_DOCUMENT seen i... @1:1) only whitespace content allowed before start tag and not i (position: START_DOCUMENT seen i... @1:1)
-
*
dojo.request.xhr code -
xhr(url, {
handleAs : "xml",
data : postData,
method : "POST",
headers : {
'Content-Type' : 'text/xml',
},
}).then(function(data){
console.log(data);
}, function(err){
console.log("Error : " + err);
});
above code is not working and giving the above mentioned error.
This is same post request using the XMLHttpRequest :-
var req = new XMLHttpRequest();
req.open("POST", url, true);
req.setRequestHeader('Content-type', 'text/xml');
req.onreadystatechange = function () {
if (req.readyState != 4) return;
if (req.status != 200 && req.status != 304) {
alert("Error");
return;
}
var xml = req.responseXML;
console.log(xml);
}
if (req.readyState == 4) return;
req.send(postData);
To check the XML(that i'm sending as postData) whether it is valid or not i used GeoServer's demo request tool to build the WFS request and its working fine.
UPDATE :- This is the link of XML file that i'm sending as a postData.
Can anyone have any idea what i'm doing wrong?? Thanks in advance.