dsDetails = new kendo.data.DataSource({
transport: {
read: {
url: PRODUCTDETAILAPI,
dataType: "json",
data: { "site_key": SITEKEY, "id": id }
}
}
});
dsDetails.fetch(function() {
var myData = dsDetails.data();
console.log(myData);
// bind stuff here
});
的API調用返回以下數據(所以我知道這是工作):錯誤獲取數據
{
"main_category": "Gifts",
"expires_on": null,
"html_address": "678 Sterling Drive\u003Cbr/\u003ESuite 102\u003Cbr/\u003ESanford FL 32771",
"address": "678 Sterling Drive Suite 102, Sanford Florida 32771",
"status": "Visible",
"rating": 5, "sub_category": "Gift Baskets",
"quantity": 92, "categories": ["Gifts: Gift Baskets"], "title": "Luggage Duffel",
"price": 12210, "images": [], "short_address": "Sanford FL",
"short_title": "Luggage Duffel",
"posted_at": "2011/09/23",
"category": "Gifts: Gift Baskets",
"id": "product_listing_88",
"price_note": "",
"description": "Black, 60 in long",
"seller": "Morning Star Media Group"
}
當我運行這段代碼,我得到了以下錯誤:
Uncaught TypeError: Object #<Object> has no method 'slice'
編輯:基於選定的答案,我用標準的jQuery .ajax調用替換這個kendo數據集代碼,它工作正常。我的大腦暫時停留在Kendo框架的範圍內。
它只是返回一個對象,或包含該對象的數組? –
只有一個對象返回從這個API – zkent