gpt4 book ai didi

javascript - 使用ajax在多个页面中发表帖子

转载 作者:行者123 更新时间:2023-11-28 07:27:28 25 4
gpt4 key购买 nike

简而言之,我有以下功能:

$(function() { // on load function, everything inside here will not run until the pagehas had time to load  
$('.filter').click(function(){
document.getElementById("results").innerHTML =
"<div class='loading-indication'><img src='ajax-loader.gif' /> &nbsp; Please wait... Loading New Courses...</div>";

var datastring = $('#testform').serialize(); // this will create key/value pairs to send to the phph page like `duration5=5` with a `&` sepparating each key/value pair
$('#display-datastring').html(datastring); // this line is just so you can see the variable being created

$.ajax({
url: 'fetch_pages.php',
type: 'post',
data: datastring,
success: function(res){
$('#results').html(res);
}
});
});
});

结果将发布到 url fetch_pages.php。简而言之,我希望将其发布在 fetch_pages.php 和以下functions/usersearch.php

最佳答案

为什么不尝试这样的事情呢?

var urls = ['fetch_pages.php','functions/usersearch.php'];

$.each(urls, function(i,url){
$.ajax(url,
{
type: 'POST',
data: datastring,
success: function (data) {
$('#results').html(data);
}
});
});

关于javascript - 使用ajax在多个页面中发表帖子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29478541/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com