elliott.david 2018-09-28 22:31 采纳率: 25%
浏览 11

Ajax-将数据发布到许多页面

I'm new in ajax, and i want to send my data to multiple pages, i have "fetch.php" and "index.php", i tried to do something like this, and it does absolutely nothing.

function load_product(minimum_range, maximum_range, selection)
{
    $.ajax({
        url:{"index.php","fetch.php"},
        method:"POST",
        data:{minimum_range:minimum_range, maximum_range:maximum_range,"selection": sv},
        success:function(data)
        {
            $('#load_product').html(data);
        }
    });
}

How can i do that ?

  • 写回答

1条回答 默认 最新

  • weixin_33717117 2018-09-28 22:54
    关注

    You can not send rame request to multiple links by passing multiple urls in url. What you can do is run a loop of urls and then doing ajax calls on all the urls

    function load_product(minimum_range, maximum_range, selection)
    {
        var links = ["index.php","fetch.php"]; 
        links.forEach(function(link){
          $.ajax({
              url:link,
              method:"POST",
              data:{minimum_range:minimum_range, maximum_range:maximum_range,"selection": sv},
              success:function(data)
              {
                  $('#load_product').html(data);
              }
          });
        })
    }

    </div>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分