2011-08-16 49 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的方法,其示數。