我試圖讓我的函數返回它鑽進另一個函數的數據,但它似乎並沒有工作?我怎樣才能得到它返回的數據?爲什麼我不能.ajax(返回數據;)? jQuery的
function playerid(playername) {
$.ajax({
type: "POST",
url: "fn.php?playerid",
data: "playername="+playername,
success: function(data) {
//$("#test").text(data);
return data;
}
});
}
我想用它的另一個功能是這樣
showBids(playerid(ui.item.value));
function showBids(playerid) {
$.ajax({
type: "POST",
url: "poll.php?",
async: true,
dataType: 'json',
timeout: 50000,
data: "playerid="+playerid,
success: function(data) {
//.each(data, function(k ,v) {
//})
//$("#current_high").append(data);
setTimeout("getData()", 1000);
}
});
心不是數據??的 – ppsreejith
可能重複[jQuery的:Ajax調用成功後返回的數據(http://stackoverflow.com/questions/5316697/jquery-return-data-after-ajax-call-success) –