【发布时间】:2015-05-08 13:20:17
【问题描述】:
我有 2 个 ajax JSON 调用,第二个 URL 是从第一个传递的变量 nextURL。
第二个 ajax 函数将 NextURL 变量注册为使用 Alert(nextURL) 进行测试,但我没有得到任何数据。错误控制台指出 $('#gameBoxleft').html(data.post.title); 数据未定义。
我不确定我在第二个 ajax 调用中是否做错了什么?
// -------------- MAIN AJAX CALL FUNCTION --------------
function call_ajax(url, elem) {
$.ajax({
url: url,
method: "GET",
data: {json: 1},
dataType: "JSON"
})
// -------------- FUNCTIONS FOR AFTER AJAX DONE --------------
.done(function (data) {
// Append the box
appendBox(elem);
// LOAD GAMEBOX JSON DATA
$("#game-name").html(data.post.title);
$("#game-reels").html(data.post.custom_fields.reels);
$("#game-paylines").html(data.post.custom_fields.paylines);
$("#game-minBet").html(data.post.custom_fields.min_bet);
$("#game-maxBet").html(data.post.custom_fields.max_bet);
$("#game-jackpot").html(data.post.custom_fields.jackpot);
$("#game-info").html(data.post.custom_fields.game_info);
var nextURL = (data.previous_url) + "?json=1";
var prevURL = (data.next_url);
processTwo(nextURL);
});
}
// -------------- NEXT OBJEXT AJAX CALL FUNCTION --------------
function processTwo(nextURL) {
alert(nextURL);
$.ajax({
url: 'nextURL',
method: "GET",
data: {json: 1},
dataType: "JSON"
})
.done(function() {
$('#gameBoxleft').html(data.post.title);
});
}
【问题讨论】:
-
删除
url: 'nextURL'nextURL 周围的单引号 -
显示
console.log(data)???请 -
你只是让我捂脸,我没有在 .done(function) 中传递数据
-
问题已被编辑,现在看到答案时有点混乱......
-
抱歉,将恢复原状。