[RESOLVED] Get response text from Ajax() when sending XML
I'm using jQuery.ajax() to send XML to my sever to be saved. I'm not sure how to deal with response text in this scenario. I want to send the XML file to page.php, then have it echo back with success or failure of saving the file. I the need to get that response text and check it in my JS.
Code:
$.ajax({
url: "page.php"
, type: "POST"
, contentType: "text/XML"
, processData: false
, data: inputXML
, success: function(event, request, options) {
//read response text and send it to function saveComp()
})
, failure: ajaxError
});
as you can see I don't know where to go in my success function to get the page.php responseText.
Nevermind, I figured it out. The server response is already sent back as the first argument in the success function. Since it's pure text, I simply eval it as JSON object
This way of Posting Xml doc is not working. I tried storing an xml doc in the inputXML passed .Below is my code
function createXMLDocument(s) {
var xmlDoc;
if (window.DOMParser) {
var parser = new DOMParser();
xmlDoc = parser.parseFromString(s, 'text/xml');
} else {
xmlDoc = new ActiveXObject('Microsoft.XMLDOM');
xmlDoc.async = 'false';
xmlDoc.loadXML(s);
}
return xmlDoc;
}
Bookmarks