我想在AJAX成功中调用json数据。我仍然是操纵json和AJAX的新手。有人可以帮助我如何访问来自其他URL的json数据吗?我想比较id
和JSON数据。到目前为止,这是我的代码:
function getCard(id){
$.ajax({
type: "GET",
data: "id=" + id,
success: function(data){
#call JSON data here from another URL
# Is it possible to call another AJAX here?
}
});
}
答案 0 :(得分:1)
是的Zuma你可以在Ajax调用的Success函数中调用另一个Ajax。以下是示例:
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
答案 1 :(得分:1)
function getCard(id){
$.ajax({
type: "Get",
url: "发送请求的地址",
data: "id=" + id,
success: function(data){
#call JSON data here from another URL
# if success,you can call another AJAX.
# Is it possible to call another AJAX here?
# yes!
}
});
}
答案 2 :(得分:1)
此代码适用于您
$.ajax({
url: "url",
method: "post",
data: "id=" + id,
success:function(data) {
// success goes here
$.ajax({
url: "url",
async:false,
method: "post",
data: "id=" + id,
success:function(json) {
JSON.parse(json);
// compare data and json here
},
error: function(){
// error code goes here
}
});
},
error: function(){
// error code goes here
}
});