Ajax. phpPHPcode & lt ;! DOCTYPEhtmlPUBLIC & quot;-W3CDTDXHTML1.0TransitionalEN & quot; www. w3.orgTRxhtml1DTDxhtml1-transitional. dtd & quot; & gt; & lt; an ajax issue
Ajax. php
PHP code
Untitled DocumentScript function GetXmlHttpObject () {var XMLHttp = null; try {XMLHttp = new XMLHttpRequest ();} catch (e) {try {XMLHttp = new ActiveXObject ("Msxml2.XMLHTTP");} catch (e) {XMLHttp = new ActiveXObject ("Microsoft. XMLHTTP ") ;}} return XMLHttp;} function submit_form (tag) {XMLHttp = GetXmlHttpObject (); var aurl =" deal_ajax.php? Tag = "+ tag +" & url = "+ document. getElementById ("url "). value + ""; XMLHttp. open ("GET", aurl, true); XMLHttp. send (null); XMLHttp. onreadystatechange = function () {if (XMLHttp. readyState = 4 & XMLHttp. status = 200) {document. getElementById ("status "). innerHTML = XMLHttp. responseText ;}} script
Deal_ajax.php
PHP code
Click the "save" button to submit it to deal_ajax.php asynchronously, but the form action will be taken immediately !!!! Post is also used
------ Solution --------------------
------ Solution --------------------
Type = "submit"
Change
Type = "button"
------ Solution --------------------
Onclick = "submit_form ('later'); return false"
------ Solution --------------------
PHP code
echo "
" . "