Sending GET/POST request with dhtmlxAjax
Add your own parameters and submit AJAX Request*. Output will contain xml with all parameters server got.
Add your own parameters and submit AJAX Request*. Output will contain xml with all parameters server got.
<script src="../../codebase/dhtmlxcommon.js"></script> <script></script> <h3>Parameters: <input type="Text" value="param1=value¶m2=value" id="params" style="width:300px;"> <button onclick="sendRequestGet()">GET</button> <button onclick="sendRequestPost()">POST</button> <input type="checkbox" id="sync"> Use Synchronous Mode</h3> * - this sample requires PHP to run correctly and show what it has to show. Unfortunately there is no possiblity to process submitted parameters and output results wthout server side programming. But syntax which was demonstrated in this sample suits for ststic XML files also.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("php/process.php?" + encodeURI(document.getElementById('params').value), outputResponse); alert("Request Sent"); } else { var loader = dhtmlxAjax.getSync("php/process.php?" + encodeURI(document.getElementById('params').value)); alert("Request Sent"); outputResponse(loader); } } function sendRequestPost() { if (!document.getElementById('sync').checked) { dhtmlxAjax.post("php/process.php", encodeURI(document.getElementById('params').value), outputResponse); alert("Request Sent"); } else { var loader = dhtmlxAjax.postSync("php/process.php", encodeURI(document.getElementById('params').value)); alert("Request Sent"); outputResponse(loader); } }