作者:老谢2502887117 | 来源:互联网 | 2017-05-14 02:21
ajax同步模式的浏览器兼容问题upload.phpPHPcode<!DOCTYPEhtmlPUBLIC"-W3CDTDXHTML1.0TransitionalEN""www.w3.orgTRxhtml1DTDxhtml1-transitional.dtd"&
ajax同步模式的浏览器兼容问题
upload.php
PHP codehttp://www.CodeHighlighter.com/-->f
后台upload_deal.php
PHP codehttp://www.CodeHighlighter.com/--> if($_REQUEST['hour']==1) { echo "true"; } else { echo "false"; }
想实现将hour提交到后台判断,再根据返回值,true正确则提交表单、跳转,false错误则不提交表单、不跳转、给出提示。但是这个代码在firefox和谷歌等非ie内核的浏览器没有问题,但是使用ie(我这是9)就全部都跳转了。尝试加上回调函数的状态判断onreadystatechange,但是所有浏览器就都不执行了,一过onreadystatechange就直接到最后的return了。
PHP codehttp://www.CodeHighlighter.com/--> XMLHttp.Onreadystatechange=function() { if(XMLHttp.readyState==4&&XMLHttp.status==200) { var resTest=XMLHttp.responseText; resTest=resTest.trim(); var response_compent="true"; if(resTest!=response_compent) { document.getElementById("status").innerHTML=resTest; } else flag=true; } }
------解决方案--------------------搜了搜,Javascript没有trim()方法吧? resTest=resTest.trim();
------解决方案--------------------