0
我正在使用WCF的Jquery,並且我正在努力獲取值,當它作爲WCF服務的數組返回時。
這裏是我的jQuery代碼:
$(document).ready(function() {
$('#Button1').click(function() {
alert('Getting Data....');
$.getJSON("http://localhost:21030/Service1.svc/GetData", { "strval": "1" }, function (data) {
// $.each(data.d, function (n, val) { alert(val); });
alert(data);
});
});
});
而這裏的這實際上是由WCF服務返回的JSON ...
{"d":["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59","60","61","62","63","64","65","66","67","68","69","70","71","72","73","74","75","76","77","78","79","80","81","82","83","84","85","86","87","88","89","90"]}
我怎樣才能真正得到這個數組並填充它們作爲一個列表在頁面上?
編輯:如果我在alert(data)
上保留斷點,斷點甚至不會觸及那條線。它似乎沒有超越$.getJSON
。任何想法爲什麼?
你的代碼應該工作。你是通過Firebug運行的,看看AJAX調用的響應是什麼?你也可以用'$ .get'替換'$ .getJSON',看看會發生什麼。 – 2010-02-06 11:28:32
你想填充背後的代碼或JavaScript對象列表的通用列表嗎? – nemke 2010-02-06 11:28:42
看起來不錯,什麼不工作? – 2010-02-06 11:28:59