2013-03-25 90 views
-1

我有一个演示使用jquery ajax后。它可以在Chrome和Firefox上运行,但不能在IE10上运行。这是我的演示:http://jsfiddle.net/44T5D/。请帮我解决这个问题。感谢您的帮助。Ajax无法在IE10上工作

代码:

$(function() { 

    $('.document').on('click', '.ajax', function(e) { 
     e.preventDefault(); 

     // ajax request 
     $.ajax({ 
      async: true, 
      cache: false, 
      type: 'post', 
      url: '/echo/html/', 
      data: { 
       html: '<p>This is echoed the response in HTML format</p>', 
       delay: 1 
      }, 
      dataType: 'html', 
      beforeSend: function() { 
       console.log('Fired prior to the request'); 
      }, 
      success: function(data) { 
       console.log('Fired when the request is successfull'); 
       $('.document').append(data); 
       alert(data); 
      }, 
      complete: function() { 
       console.log('Fired when the request is complete'); 
      } 
     }); 

    }); 

}); 
+0

你有任何加载项,扩展或其他影响IE10的东西呢? – 2013-03-25 03:35:40

+0

我看到你的jsfiddle使用jQuery 1.7.2。你用1.9.1测试过吗? – 2013-03-25 03:36:42

+0

我不知道你说的究竟是什么附加组件或扩展。但我昨天刚刚安装了IE10,只有IE10,没有任何附件,扩展。你能告诉我更多关于这个错误吗? – user1967247 2013-03-25 03:43:10

回答

2

Internet Explorer将出错的各种console功能,除非开发者工具是开放的。由于您有一个beforeSend处理程序,所以很可能就是停止执行的地方。

要查看这是否确实是问题,请按F12打开开发人员工具并刷新页面,然后查看它是否有效。

至于如果你想保持console功能,寻找到一个控制台填充工具(一些在此列出)解决方法:Why do console.log() polyfills not use Function.apply()?

+0

)我已经修复了我的代码,删除了所有的控制台功能,使用jquery 1.9.1。它通常在chrome和FF上运行,但是在IE10中,当我单击链接时,它只显示带空白文本的警告对话框 – user1967247 2013-03-25 03:58:54

+0

My new代码如下:http://jsfiddle.net/qYXa3/ – user1967247 2013-03-25 04:01:16

+0

你在第19行有一个错位的逗号,这可能会让IE混淆。作为提示,在jsfiddle中使用JSHint按钮,它会指出类似这样的错误。 – 2013-03-25 04:05:00