2014-02-13 48 views
0

我從Web服務加載一些數據並嘗試過濾它。SCRIPT438:對象不支持屬性或方法「過濾器」IE10

var topLevelProductTypes = []; 

topLevelProductTypes = productTypesArray.filter(function (pt) { 
    return (pt.NS_designcentreproducttypeid.Id === null); 
}); 

我得到的錯誤SCRIPT438:對象不支持屬性或方法「過濾器」

+3

你在兼容模式? 'productTypesArray'真的是一個數組嗎? – Ryan

+0

此代碼在CRM 2011中的Web資源上運行。我使用xmm端點爲crm將json數據推入productTypesArray。 – smoss

+0

>> productTypesArray [0] { \t [原型]:{...}, \t __metadata:{...}, \t NS_designcentreproducttypeid:{...}, \t NS_designcentretypeId:「558b2086-478e- e111-8108-0050568d0006" , \t NS_name: 「1個外殼(淋浴)」 } 添加到觀看 >> productTypesArray [0] .NS_designcentreproducttypeid.Id 「15af4efc-468e-e111-8108-0050568d0006」 > > productTypesArray [0] .NS_designcentreproducttypeid { \t [prototype] :{...}, \t __metadata:{...}, \t ID: 「15af4efc-468e-e111-8108-0050568d0006」, \t LogicalName: 「ns_designcentretype」, \t名稱: 「驟雨」 } 加入觀看 – smoss

回答

2

添加這在你的頭<meta http-equiv="X-UA-Compatible" content="IE=edge" />

而且productTypesArray看在你的代碼未申報。我會假設它被分配到一個array

if(Object.prototype.toString.call(productTypesArray) === '[object Array]') { 
    alert('It is an array'); 
} 
+0

有趣的事實:警告(Object.prototype.toString == toString);通常會保存一些擊鍵或使用({})。toString來確定。 – dandavis

+0

請勿使用「X-UA兼容」。修復真正的錯誤 - 無效的HTML 99%的時間。 – Ryan

+0

我跑了那個檢查,我得到了警報,所以productTypesArray實際上是一個數組。 – smoss

相關問題