将onreadystatechange函数放在open前即可。
ajax:
1.创建Ajax对象 ——new XMLHttpRequest;/ new ActiveXObject('Microsoft.XMLHTTP');
2.接收返回值 ——onreadystatechange
3.连接到服务器 ——open
4.发送请求 ——send
本文介绍在使用Ajax进行异步通信时,将onreadystatechange函数置于open方法前的重要性。遵循这一顺序,确保了事件监听器能够在请求状态改变时及时响应。
将onreadystatechange函数放在open前即可。
ajax:
1.创建Ajax对象 ——new XMLHttpRequest;/ new ActiveXObject('Microsoft.XMLHTTP');
2.接收返回值 ——onreadystatechange
3.连接到服务器 ——open
4.发送请求 ——send

被折叠的 条评论
为什么被折叠?