Ajax 请求中的 jQuery Ajax 请求 [英] jQuery Ajax Request inside Ajax Request
本文介绍了Ajax 请求中的 jQuery Ajax 请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在另一个 ajax 请求中发出 ajax 请求?因为我需要来自第一个 ajax 请求的一些数据来发出下一个 ajax 请求.
Is it possible to make an ajax request inside another ajax request? because I need some data from first ajax request to make the next ajax request.
首先,我使用 Google Maps API 来获取 LAT &LNG,之后我使用那个 LAT &LNG 请求 Instagram API(基于搜索的位置).
First I'm using Google Maps API to get LAT & LNG, after that I use that LAT & LNG to request Instagram API (search based location).
再说一次,这可能吗,如果可能,怎么办?
Once again, is this possible, and if so how?
$('input#search').click(function(e) {
e.preventDefault();
var source = $('select[name=state] option:selected').text()+' '+$('select[name=city] option:selected').text()+' '+$('select[name=area] option:selected').text();
var source = source.replace(/ /g, '+');
if(working == false) {
working = true;
$(this).replaceWith('<span id="big_loading"></span>');
$.ajax({
type:'POST',
url:'/killtime_local/ajax/location/maps.json',
dataType:'json',
cache: false,
data:'via=ajax&address='+source,
success:function(results) {
// this is where i get the latlng
}
});
} else {
alert('please, be patient!');
}
});
推荐答案
这是一个例子:
$.ajax({
type: "post",
url: "ajax/example.php",
data: 'page=' + btn_page,
success: function (data) {
var a = data; // This line shows error.
$.ajax({
type: "post",
url: "example.php",
data: 'page=' + a,
success: function (data) {
}
});
}
});
这篇关于Ajax 请求中的 jQuery Ajax 请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文