Jquery 不';Internet Explorer 7,8中的t work ajax超时和错误
这个简单的代码:Jquery 不';Internet Explorer 7,8中的t work ajax超时和错误,jquery,ajax,internet-explorer,timeout,Jquery,Ajax,Internet Explorer,Timeout,这个简单的代码: <html> <head></head> <body> <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script> $(function() { var d = new Date(); $( "#new" ).click(
<html>
<head></head>
<body>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
$(function() {
var d = new Date();
$( "#new" ).click(function() {
$.ajax({
type: "POST",
url: "./work.php?_="+d.getTime(),
cache: false,
timeout: 20000,
success: function(msg){
alert("Hello!");},
error: function (data, status, e)
{
if(status == "abort") alert("Cancel"); else
if(status == "timeout") alert("TimeOut"); else
alert("Error: "+status+" "+e);
}
});
});
});
</script>
<input type=button id=new />
</body>
</html>
$(函数(){
var d=新日期();
$(“#新建”)。单击(函数(){
$.ajax({
类型:“POST”,
url:“./work.php?=“+d.getTime(),
cache:false,
超时:20000,
成功:功能(msg){
警告(“你好!”;},
错误:功能(数据、状态、e)
{
如果(状态==“中止”)警报(“取消”);否则
如果(状态==“超时”)警报(“超时”);否则
警报(“错误:+状态+”+e);
}
});
});
});
和work.php:
<?php
sleep(14);
?>
在Firefox、Chrome、Opera和Intenet Explorer 9中,大约14秒时输出警报“Hello!”。在InternetExplorer7,8中,大约10秒时发出警报“错误:错误未知”
错在哪里?如何获得20秒的超时时间?您是否尝试定义
数据类型
?对。数据-d.getTime(),例如针对缓存internet explorer。