2011-08-16 51 views
3

虽然IE 9测试我的jQuery脚本它显示了错误的jQuery的1.6.2.js - 使用中没有问题的工作的Internet Explorer 9在兼容模式下显示错误

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

我的js文件其他浏览器 - Firefox 3.6,5.0,歌剧11,铬,铬。我不明白。在jquery源代码中是否存在错误,或者在我的js文件中是否存在错误?我如何找到它?

自从我在这个领域开始以来,这已经很长时间了,所以请我真的很感激一些想法。

预先感谢您。

[编辑] 我已经添加了完整的代码。 我学到了: http://net.tutsplus.com/tutorials/javascript-ajax/how-to-create-a-jquery-image-cropping-plug-in-from-scratch-part-ii/

我不知道要添加哪个部分。整个代码不适合在stackoverflow的提交。 “身体被限制为3000个字符;你输入了42121”

[第二编辑] 我在我的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"); 
        } 
     }); 
    }; 
+0

我的代码是否需要?我正在创建一个jQuery插件,我不知道从哪里产生错误。 – maan81

+0

你的代码将很高兴看到:) –

+1

上面的错误处理程序不能是原因,它是一个不同于jQuery.error() –

回答

2

我描绘出我的问题。即,从http://api.jquery.com/attr阻止属性的改变这让对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." 

,刚过1号预警通知。

所以我改变了我的代码从早期

$('input').clone() 

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

,它解决了我的问题。

谢谢大家。

0

只是猜测,但你是否在某处使用$ .error()在你的代码中?如果是的话:不要使用它。


<edit> 

然而,这个错误来自jQuery.error()

原来的误差函数如下:

error: function(msg) { 
     throw msg; 
    } 

你可以测试它没有jQuery的:

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

你会得到同样的错误。

如果你不使用jQuery.error()也许你使用一些使用它的插件。 您可以通过执行下面的权后的嵌入的jquery.js覆盖此(车?)函数:

jQuery.error=function(){} 

</edit> 
+0

没有使用过。 – maan81

0

jQuery.error()(其throws作为参数传递的消息),是在指定的处理程序error完全不同的一个AJAX调用。

jQuery.error()用于internally by jQuery(搜索“错误(”)。你应该调试代码,并按照堆栈跟踪找出其中你的方法被调用jQuery的方法,其示数。