在开发中,难免会碰到需要发送两次ajax请求或者更多的情况

情境:我们需要resultB数据,后台提供的接口要先传入参数paramA,获取到resultA,然后resultA作为参数,调用另外一个接口才能获取到resultB,这种情形就需要两个请求才能实现

代码模板

      $.ajax({
                  type:'get',
                  url:'http://127.0.0.1:8004/rest/video/getInterfaceA',
           data:{panoramA: 'panoramA'}, dataType:
'json', success:function( data ) { $.ajax({ type:'get', url:'http://127.0.0.1:8004/rest/video/getInterfaceB',
               data:{resultA: 'resultA'}, dataType:
'json', success:function( data ) { alert('test'); }, error:function(data) {} }); }, error:function(data) { } });

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-04
  • 2021-08-28
  • 2022-12-23
  • 2021-08-29
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
  • 2021-07-16
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案