在另一个ajax请求中发出ajax请求是否可能? 因为我需要第一个ajax请求中的一些数据来进行下一个ajax请求。
首先我使用Google Maps API获取LAT和LNG,然后使用这些LAT和LNG请求Instagram API(基于位置搜索)。
如果可能的话,如何实现呢?
$('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!');
}
});