今天发现国内的AJAX异步传输教程都有一个致命错误,如果你按照教程做是可以实现页面的更新,但无法实现第二次更新,也就是说你无法再次通过这个方法再 次刷新页面。比如你有一个列表,需要根据列表里的每项显示不同的内容,这时你如果用教程的方法就不行,为什么呢,因为教程一个语句的顺序写反了:
p.onreadystatechange = processajaxresponse;
这句一定要放在open语句之后,像这样
p.open("post", "script/post.php", true);
p.onreadystatechange = processajaxresponse;
p.setrequestheader("content-type", "application/x-www-form-urlencoded");
p.send(stra);
相关文章:
-
2021-09-27
-
2022-12-23
-
2021-12-26
-
2021-12-18
-
2021-09-19
-
2022-12-23
-
2022-12-23
-
2022-12-23
猜你喜欢
-
2021-10-23
-
2022-12-23
-
2022-12-23
-
2021-10-28
-
2021-09-27
-
2021-11-03
相关资源
-
下载
2023-01-03
-
下载
2023-02-17
-
下载
2021-06-06