2013-10-23 82 views
0

使用jQuery-1.7.2.min.jsSCRIPT5009: '串' 未定義IE9

我有以下的javascript:

$(function() { 
    $("#del_category").click(function() { 
     if (confirm('Are you sure you want to delete this category?')) { 
      $.ajax({ 
       type: "POST", 
       url: "someurl", 
       datatype: "json", 
       csd: window.parent.CSD, 
       success: function(data) { 
        if (data.isSuccess) { 
         if (data.isFree) { 
          // error appears if this function invokes 
          this.csd.Popup.currentWindow.hideDialog(); 
         } else { 
          alert("Category uses in some FAQ."); 
         } 
        } else { 
         alert("Error. Category was not deleted."); 
        } 
       } 
      }); 
     } 

     return false; 
    }); 
}); 

它工作正常,除了IE9所有瀏覽器。在IE9中它正常工作(所有函數調用),但顯示js錯誤:SCRIPT5009:'字符串'未定義

我該如何解決這個問題?

編輯

這個腳本工作沒有錯誤:

$(function() { 
    $("#del_category").click(function() { 
     window.parent.CSD.Popup.currentWindow.hideDialog(); 
    }); 
}); 

錯誤只出現在阿賈克斯的onSuccess事件處理程序。

+0

在您顯示的代碼中沒有對'String'的引用。你能給我們一些導致錯誤的代碼嗎? –

+0

小提琴或現場? –

+0

它出現在509行的jquery-1.7.2.js中: 類型:function(obj){ return obj == null? String(obj):class2type [oString.call(obj)] || 「目的」; }, – Neshta

回答

0

試着把hideDialog();放在setTimeout的內部。我相信這個錯誤即將出現,因爲在jQuery完成之前對話正在被拋棄。

$(function() { 
    $("#del_category").click(function() { 
     if (confirm('Are you sure you want to delete this category?')) { 
      $.ajax({ 
       type: "POST", 
       url: "someurl", 
       datatype: "json", 
       csd: window.parent.CSD, 
       success: function(data) { 
        if (data.isSuccess) { 
         if (data.isFree) { 
          // error appears if this function invokes 
          var csd = this.csd; 
          setTimeout(function() { 
           csd.Popup.currentWindow.hideDialog(); 
          }, 0); 
         } else { 
          alert("Category uses in some FAQ."); 
         } 
        } else { 
         alert("Error. Category was not deleted."); 
        } 
       } 
      }); 
     } 

     return false; 
    }); 
});