Ajax请求中的jQuery Ajax请求

前端之家收集整理的这篇文章主要介绍了Ajax请求中的jQuery Ajax请求前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
是否可能在另一个ajax请求内部发出ajax请求?
因为我需要从第一个ajax请求的一些数据,以进行下一个ajax请求。

首先,我使用Google Maps API获取LAT& LNG,之后我使用LAT& LNG请求Instagram API(基于搜索的位置)。

再次,这是可能的,如果是如此?

  1. $('input#search').click(function(e){
  2. e.preventDefault();
  3. var source=$('select[name=state] option:selected').text()+' '+$('select[name=city] option:selected').text()+' '+$('select[name=area] option:selected').text();
  4. var source=source.replace(/ /g,'+');
  5. if(working==false){
  6. working=true;
  7. $(this).replaceWith('<span id="big_loading"></span>');
  8. $.ajax({
  9. type:'POST',url:'/killtime_local/ajax/location/maps.json',dataType:'json',cache: false,data:'via=ajax&address='+source,success:function(results){
  10. // this is where i get the latlng
  11. }
  12. });
  13. } else {
  14. alert('please,be patient!');
  15. }
  16. });
这里是一个例子:
  1. $.ajax({
  2. type: "post",url: "ajax/example.PHP",data: 'page=' + btn_page,success: function (data) {
  3. var a = data; // This line shows error.
  4. $.ajax({
  5. type: "post",url: "example.PHP",data: 'page=' + a,success: function (data) {
  6.  
  7. }
  8. });
  9. }
  10. });

猜你在找的Ajax相关文章