抱歉,但我无法理解这些例子。我从今天开始学习ajax。任何人都可以解释我的示例脚本,我发现谷歌
我已经明白到目前为止
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
,但在下面的脚本
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
为什么我们使用document.getElementById("txtHint").innerHTML=xmlhttp.responseText
下面的脚本。我不明白我们为什么要这样做。任何人都可以向我解释这些,我不确定上述脚本是否可选,请让我知道。
也POST方法在阿贾克斯
xmlhttp.open("POST","test.php",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("fname="+str);
什么用xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
Im的无法理解它的参数,以及为什么它正在使用,它到底在做剧本。我们怎么通过content-type
和application/x-www-form-urlencoded
和仍在工作的意思是,即使我不给任何用户选项
请帮助我,这些都那么相信我已经完成了阿贾克斯tutorials.Thanks
为了理解你对AJAX的要求,你需要了解一些关于HTTP协议的知识。包括“响应标题”,“内容类型”和“HTTP状态”。这个链接有一些很好的信息:http://www.w3schools.com/ajax/ – paulsm4 2012-01-09 07:34:58