jQuery Ajax响应&“未定义&"使用Internet Explorer
问题描述:
我遇到了jquery ajax请求的情况.
I've got a situation with jquery ajax requests.
<script type="text/javascript">
$(document).ready(function() {
$.ajax({
type: "POST",
async: false,
cache: false,
url: "/ajax/script.php",
data: { display: 'user', user_id: '1'}
}).done(function( msg ) {
if (msg !== "") {
alert(msg);
}
});
});
</script>
使用Chrome& Firefox我有由脚本/ajax/script.php
生成的html代码
使用IE8(我没有尝试过6、7和9+),我有Undefined
With Chrome & Firefox I've html code generate by the script /ajax/script.php
With IE8 (I've not tried with 6, 7 and 9+) I have Undefined
有人知道该如何解决吗?
Do someone knows how to fix that?
我正在使用jquery 1.7.2
I'm using jquery 1.7.2
答
返回application/json; charset=utf8
的MIMEType对我来说在IE8中也引起了同样的问题.将其更改为application/json;
可使IE8神奇地开始运行.
Returning the MIMEType of application/json; charset=utf8
caused this same behavior for me in IE8. Changing it to application/json;
made IE8 magically start functioning.