【发布时间】:2012-04-22 18:49:48
【问题描述】:
是否可以在另一个 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!');
}
});
【问题讨论】:
-
是的,有可能
-
你能发布你到目前为止的代码吗?
-
我已经编辑了我的问题,代码在上面
标签: jquery ajax google-maps instagram