开发者

Internet Explorer 9 in compatibility-mode shows error

开发者 https://www.devze.com 2023-03-28 15:27 出处:网络
While testing my jQuery script in IE 9 it shows error in jquery-1.6.2.js -- SCRIPT5022: Exception thrown and not caught

While testing my jQuery script in IE 9 it shows error in 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. I do not understand. Is there a bug in the jquery source or is there a bug in my js file ? 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/

I don't know which part to add. The whole code does not fit in stackoverflow's submit. says "body is limited to 3000 characters; you entered 42121 "

[2nd edit] I have used 'error' in my ajax submit.

    //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.

 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.

So I changed my code from earlier

$('input').clone() 

to

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

and it solved my problem.

Thanks everyone.


jQuery.error() (which throws the message passed as an argument), is totally different to the error handler specified in an AJAX call.

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.


Just a guess, but do you somewhere use $.error() inside your code? If yes: don't use it.


<edit>

However, this error comes from jQuery.error().

The original error-function looks like this:

error: function( msg ) {
        throw msg;
    }

You may test it without 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. You may override this (buggy?) function by executing the following right after the embedded jquery.js:

jQuery.error=function(){}

</edit>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号