我想知道是否有可能獲得JQuery的方法的getJSON的外部訪問返回的JSON數據..這樣的事情之外..JQuery的/ JSON - 需要將數據訪問由JSON返回的代碼塊
var price = "";
$.getJSON("../JSONDeliveryPrice", null, function (data) {
price = eval(data.price);
});
console.log(price);
這是行不通的,有沒有另外一種方法可以獲得價格以外的價格?
異步代碼 – jantimon 2012-01-17 08:36:13
您需要使用同步請求。這是偉大的答案熱做到這一點:http://stackoverflow.com/questions/933713/is-there-a-version-of-getjson-that-doesnt-use-a-call-back – Samich 2012-01-17 08:36:33
使呼叫同步向後。處理響應的代碼必須位於(或調用)[傳遞給'getJSON'的繼續](http://stackoverflow.com/questions/31129/how-can-i-return-a-variable-from-一個-的getJSON函數)。 – outis 2012-01-18 06:43:00