一个ajax的问题
ajax.php
- PHP code
<!---ecms Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><script> 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&g<strong>(本文来源gaodai#ma#com搞@@代~&码网</strong><pre>搞代gaodaima码
t;<body>
url | |
message | |
deal_ajax.php
- PHP code
<!---ecms Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?phpecho "#######@".$_REQUEST['url'];?>
点击“保存”按钮可以异步提交到deal_ajax.php,但是马上就走form的action了!!!!用post也是
——解决方案——————–
——解决方案——————–
type=”submit”
改成
type=”button”
——解决方案——————–
onclick=”submit_form(‘later’);return false”
——解决方案——————–
- PHP code
echo "<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />" . "<script type='text/javascript' language='javascript'>". "if(confirm('ok')){" . " window.location.href='{$href}';" . "} else{ history.back(); }" . "</script>"; exit;