我只是想了解ajax
函数的编码流程。让我举一个简单的例子,为什么不ajax fn()遵循代码序列
function test() { alert("Hello"); alert("World"); }
如果你运行该功能,第一个对话框会Hello
和第二会World
,对不对?但是为什么在ajax中编码结构不会以相同的方式通过。
ajaxRequest.open("POST", "pos/write", true);
ajaxRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
ajaxRequest.send("user=Ram"); /* this line can be written anywhere */
ajaxRequest.onreadystatechange = function() {
if(ajaxRequest.readyState == 4 && ajaxRequest.status == 200){
alert("done"); }
// ajaxRequest.send("user=Ram");
,你可以看到,.send('user=Ram')
上面写&的.readyState
下方,但在这两种情况下成功运行。 这就是我想明白了,为什么不ajax
FN()遵循代码序列
你的js看起来像是在最后缺少一些东西...... – Ben
@Ben:是的,我只是写了一些部分的js,我没有明白这一点。 – user1010399