我有一些代码在Chrome中完美工作,但它在IE中出错。 if条件在chrome中完美工作,但似乎在IE中,第一个条件总是被执行,而不管resData的值如何。我wiresharked响应,并且数据包包含'开始',但它仍然在第一条件如果条件if(resData ==='不runnin')。
$.get('/getOutputBuffer', function(resData){
if(resData === 'not running'){
$('#output').append('Executable not started<br>');
}
else{
$('#output').append('Executable started (Now listening)<br>');
if(resData !== 'no updates'){
$('#output').append('status is ' +resData);
}
}
});
编辑:
我已经改变了所有的条件,如果用 “==”。
经过更多的调试,它并不总是执行第一个条件,ajax函数似乎是问题所在。它在页面加载后第一次执行时会获得正确的数据值,但是任何其他GET都会给我第一个值,即使在wireshark中它也会显示正确的更新值。
问题确实存在。更改$ .get为$ .post,并更改我的get请求服务器端的帖子,这一切工作。原因是post不会在每次请求后缓存,就像相应的规范一样。有趣的是,铬不遵循这一点,但IE浏览器。 – guiomie 2012-01-03 20:57:53