Why is my AJAX-call failing in Google Chrome?

I am curious as to why my AJAX-call is failing in Google Chrome, it works perfectly fine in Firefox. Before anyone asks, no I'm not using JQuery because I need to have access to readyState == 3 which JQuery doesn't seem to have. My script currently looks like this(with large unneccessary parts stripped out): function fetch() { main = new XMLHttpRequest(); main.open("GET", "", true); var lastResponse = ''; var statusString = 'Step 1(of 3), please wait... '; main.onreadystatechange = function() { if( main.readyState == 1 ) { alert('Fetch!'); $("#ajax-status").html( statusString ); } // If there's been an update if( main.readyState == 3 ) { } if( main.readyState == 4 ) { } }; main.send(null); } It works perfectly in Firefox but in Chrome it doesn't even alert anything so it doesn't even get into readyState 1(which is when you send it) -- that seems rather odd.. Any ideas??

以上就是Why is my AJAX-call failing in Google Chrome?的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准