简体   繁体   English

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

[英]Ajax - post data to many pages

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. 我是ajax的新手,我想将数据发送到多个页面,我有“ fetch.php”和“ index.php”,我试图做这样的事情,但它绝对不起作用。

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 ? 我怎样才能做到这一点 ?

You can not send rame request to multiple links by passing multiple urls in url. 您不能通过在URL中传递多个URL将rame请求发送到多个链接。 What you can do is run a loop of urls and then doing ajax calls on all the urls 您可以做的是运行一个URL循环,然后对所有URL进行Ajax调用

 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); } }); }) } 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM