Ajax在IE10上不起作用 [英] Ajax not work on IE10

查看:252
本文介绍了Ajax在IE10上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a demo use jquery ajax post. It can run on Chrome and Firefox, but not in IE10. This is my demo: http://jsfiddle.net/44T5D/. Please help me to solve this problem. Thanks for you help.

代码:

$(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');
            }
        });

    });

});

推荐答案

除非打开开发人员工具,否则Internet Explorer将在各种console函数上出错.有了beforeSend处理程序,很有可能是它停止执行的地方.

Internet Explorer will error on the various console functions unless the developer tools are open. As you have a beforeSend handler, more than likely that's where it's stopping execution.

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

To see if this is indeed the issue, press F12 to open up the developer tools and refresh the page, and see if it works.

作为解决方法,如果要保留console功能,请查看控制台polyfill(此处列出了其中的一些内容):

As a workaround if you want to keep the console functions, look into a console polyfill (some are listed here): Why do console.log() polyfills not use Function.apply()?

这篇关于Ajax在IE10上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆