简体   繁体   English

兼容模式下的 Internet Explorer 9 显示错误

[英]Internet Explorer 9 in compatibility-mode shows error

While testing my jQuery script in IE 9 it shows error in jquery-1.6.2.js --在 IE 9 中测试我的 jQuery 脚本时,它在 jquery-1.6.2.js 中显示错误——

SCRIPT5022: Exception thrown and not caught 
jquery-1.6.2.js, line 548 character 3

My js file used to work with no problems in other browsers - firefox 3.6, 5.0, opera 11, chromium, chrome.我的 js 文件曾经在其他浏览器中没有问题 - firefox 3.6、5.0、opera 11、chromium、chrome。 I do not understand.我不明白。 Is there a bug in the jquery source or is there a bug in my js file? jquery 源代码中有错误还是我的 js 文件中有错误? How do I find it?我如何找到它?

It hasen't been long since I started in this area so please I would really appreciate some ideas.自从我开始从事这个领域以来已经不久,所以请我真的很感激一些想法。

Thank you in advance.先感谢您。

[edited] I've added the complete code. [编辑] 我已经添加了完整的代码。 I've learnt from: http://net.tutsplus.com/tutorials/javascript-ajax/how-to-create-a-jquery-image-cropping-plug-in-from-scratch-part-ii/我从中学到了: http://net.tutsplus.com/tutorials/javascript-ajax/how-to-create-a-jquery-image-cropping-plug-in-from-scratch-part-ii/

I don't know which part to add.我不知道要添加哪个部分。 The whole code does not fit in stackoverflow's submit.整个代码不适合 stackoverflow 的提交。 says "body is limited to 3000 characters; you entered 42121 "说“正文限制为 3000 个字符;您输入了 42121”

[2nd edit] I have used 'error' in my ajax submit. [第二次编辑] 我在 ajax 提交中使用了“错误”。

    //jquery ajax submit for resizing
    function submit(myform,e){
        $n.val($image.attr('src').replace(/^[^,]*\//,''));

        var mydata = myform.serialize();
        $.ajax({
            url: $myform.attr('action'),
            cache: false,
            type:$myform.attr('method'),
            data: mydata,

            success: function(response){
                var img = $("<img />").attr('src', 'images/'+response+'?'+ e.timeStamp) //<-- img name here
                    .load(function() {
                       if (!this.complete || typeof this.naturalWidth == "undefined" || this.naturalWidth == 0) {
                           alert('Incorrect image.');

                       } else {
                           $("#result").html(img); //<-- put cropped img here.

                       }
                    });


                    },
            error: function(){ //<-- error used here
                        $('#result').html("Err. Loading Image");
                    }
        });
    };

I traced out my problem.我找出了我的问题。 IE prevented changing of attribute which let to the jQuery error. IE 阻止更改导致 jQuery 错误的属性。

 Note: jQuery prohibits changing the type attribute on an or element and
 will throw an error in all browsers. This is because the type attribute 
 cannot be changed in Internet Explorer." 

from http://api.jquery.com/attr , just after 1st warning notice.来自http://api.jquery.com/attr ,就在第一次警告通知之后。

So I changed my code from earlier所以我从之前更改了我的代码

$('input').clone() 

to

$('<input />').attr({'type':'hidden'})

and it solved my problem.它解决了我的问题。

Thanks everyone.感谢大家。

Just a guess, but do you somewhere use $.error() inside your code?只是一个猜测,但是您是否在代码中的某个地方使用了 $.error() ? If yes: don't use it.如果是:不要使用它。


<edit>

However, this error comes from jQuery.error() .但是,此错误来自jQuery.error()

The original error-function looks like this:原始错误函数如下所示:

error: function( msg ) {
        throw msg;
    }

You may test it without jquery:您可以在没有 jquery 的情况下对其进行测试:

(function( msg ) {
        throw msg;
    })('errormessage');

You'll get the same error.你会得到同样的错误。

If you don't use jQuery.error() maybe you use some plugin that uses it.如果你不使用jQuery.error()也许你使用了一些使用它的插件。 You may override this (buggy?) function by executing the following right after the embedded jquery.js:您可以通过在嵌入式 jquery.js 之后执行以下操作来覆盖此(错误?) function:

jQuery.error=function(){}

</edit>

jQuery.error() (which throws the message passed as an argument), is totally different to the error handler specified in an AJAX call. jQuery.error()throws作为参数传递的消息)与 AJAX 调用中指定的error处理程序完全不同。

jQuery.error() is used internally by jQuery (search for "error("). You should debug your code and follow the stack trace to find which of your methods is calling the jQuery method which is erroring. jQuery.error() jQuery

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM