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"?> 1Changes sucessfully made.



Upon running I consistently get:



Error type: LoadXML

Description: Incorrect XML



in a JS alert type popup.


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.

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”);
}