Categories | Question details Back To List | ||
LoadXML error in doXPath My Code: NB - pButtonToken is either "open" or "close" ------------------------------------------------------------ var answer = confirm("Please confirm that you wish to " + pButtonToken + " the selected surveys."); selectedRows = objsurveyList.getCheckedRows(0); endpoint = "/ajax/setProgramOpenClose.php" parms = "pgmId="+selectedRows+"&action="+pButtonToken; if (answer){ var loader = dhtmlxAjax.postSync(endpoint, parms); console.log(loader.xmlDoc.responseXML); console.log(loader.xmlDoc.responseText) var result = loader.doXPath("/"); for(var i=0;i<result.length;i++){ console.log(result[i].nodeName); } } ------------------------------------------------------------ From the console (via Firebug): loader.xmlDoc.responseXML = null loader.xmlDoc.responseText = <?xml version="1.0" encoding="ISO-8859-1"?> <result><value>1</value><message>Changes sucessfully made.</message></result> Upon running I consistently get: Error type: LoadXML Description: Incorrect XML in a JS alert type popup. Answer posted by Alex (support) on Jun 24, 2009 06:41 Please, check that "/ajax/setProgramOpenClose.php" returns the correct xml that corresponds following statements: - the content type is text/xml - there are no spaces before <?xml declaraton To check, if the xml is correct, try to open the page in browser. The xml will be shown if it's correct. Answer posted by Eric Stauffer on Jun 24, 2009 07:02 You were exactly correct. I omitted the following code from my PHP: if (stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml")) { header("Content-type: application/xhtml+xml"); } else { header("Content-type: text/xml"); } |