下面是我使用的代码。我正在尝试执行“回调”,因为在脚本中使用ajax会有多个不同的调用,因此我想要一个函数来处理所有这些。这是以下功能的最基本版本。jquery ajax返回undefined json
function gd(callback){
$.ajax(
{
type: "GET",
dataType: "json",
url: ad + "?a=vocab&lessonID=" + lessonID + "&offset=" + offset + '&nocache=' + (new Date()).getTime(),
success: function(response) {
callback(response);
},
error: function(jqXHR, exception) {alert('error');}
});
}
function test(response){
alert('hi' + response);
}
gd(test()); // returns undefined
我怎样才能让这个我不得到不确定的和正确获得JSON对象要能够调用GD后对其进行操作测试()函数中(测试())