假設返回值是一個數組:
$.when.apply(do_it[1,2,3]).then(function(data){
$(JSON.parse.(data)).each(function(index, element){
//do stuff
});
}, function() {console.log('Failed');<br>});
編輯:
從你的意見,讓我們假設:
var data = '[{"ID":1,"L_Name":"Jones","F_Name":"Jan","Email":"[email protected]","Telephone_No":"xxx.xxx.xxxx","Institution":"IT","Department":"3","Notes":"","Secretary":0},{"ID":3,"L_Name":"Smith","F_Name":"Christopher","Email":"[email protected]","Telephone_No":"","Institution":"IT","Department":"18","Notes":"","Secretary":0},{"ID":4,"L_Name":"White","F_Name":"Amanda","Email":"[email protected]","Telephone_No":"","Institution":"UT","Department":"25","Notes":"","Secretary":0}]';
通知我增加了開閉括號用於數組和元素之間的逗號。
然後通過數組循環,你可以這樣做:
var json = JSON.parse(data);
$(json).each(function(index,element){
//do stuff
alert("index: " + index + " element: " + element);
});
對不起,我的錯字。這就是我的代碼....修正了。 – user135650
JSON的外觀如何? – Andy
這裏有很多奇怪的事情發生。你能否用簡單的英文詳細描述你想要做什麼? –