var xmlhttp=createxmlhttprequestobject(); //get xmlhttprequest object function createxmlhttprequestobject(){ var xmlhttp; if(window.activexobject){ try{ xmlhttp=new activexobject(microsoft.xmlhttp); } catch(e){ xmlhttp=false; } }else{ try{ xmlhttp=new xmlhttprequest(); } catch(e){ xmlhttp=false; } } if(!xmlhttp){ }else{ return xmlhttp; } } function process(){ if(xmlhttp.readystate==4||xmlhttp.readystate==0){ name=document.getelementbyid(myname).value; xmlhttp.open(get,quickstart.php?name=+name,true); xmlhttp. xmlhttp.send(null); }else{ settimeout('process()',1000); } } function handleserverresponse(){ if(xmlhttp.readystate==4){ if(xmlhttp.status==200){ xmlresp xmldocumentelement=xmlresponse.documentelement; hellomessage=xmldocumentelement.firstchild.data; document.getelementbyid('divmessage').innerhtml=''+hellomessage+''; settimeout('process()',1000); }else{ alert('there was a problem accessing hte server:'+xmlhttp.statustext); } } }
php代码:
遇到了 一个
warning: cannot modify header information - headers already sent by....
的问题。解决方法:
修改php.ini文件,
我用的是阿里的服务器所以
启用如下如的功能就可以了。
等),以防止出错。
以上就介绍了ajax与php,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。
