Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Jame Chiang on Jun 28, 2009 04:07
open dhtmlx forum
dhtmlajax sample program

1. test “dhtmlajax” sample program: send_request.html
<script>
function outputResponse(loader){
    if(loader.xmlDoc.responseXML!=null)
        alert("We Got Response\n\n"+loader.doSerialization())
    else
        alert("Response contains no XML")
}

function sendRequestGet(){
    if(!document.getElementById('sync').checked){
        dhtmlxAjax.get("process.php?"+document.getElementById('params').value,outputResponse);
        alert("Request Sent");
        }else{
        var loader = dhtmlxAjax.getSync("process.php?"+document.getElementById('params').value);
        alert("Request Sent");
        outputResponse(loader)
        }
}

function sendRequestPost(){
    if(!document.getElementById('sync').checked){
        dhtmlxAjax.post("process.php",document.getElementById('params').value,outputResponse);
        alert("Request Sent");
    }else{
        var loader = dhtmlxAjax.postSync("process.php",document.getElementById('params').value);
        alert("Request Sent");
        outputResponse(loader)
    }
                
}
</script>

2. change "process.php" to "process.aspx", they do same things

3. always get “We Got Response” message, even program name change to an not exist
Answer posted by Support on Jun 29, 2009 02:26
With above code, "We Got Response" message will appear each time when response can be parsed as XML, so if 404 page in your case returns valid xHTML content - it will be parsed as XML. 
You can change your code as 


function outputResponse(loader){
  if(loader.xmlDoc.responseXML!=null && loader.xmlDoc.doXPath("/top_tag")
     alert("We Got Response\n\n"+loader.doSerialization()) 
else
     alert("Response contains no XML") 
}

where top_tag - name of top tag in XML