gpt4 book ai didi

php - jQueryeach()结果数组到php到数据库

转载 作者:行者123 更新时间:2023-12-01 06:06:09 26 4
gpt4 key购买 nike

基本上我正在做的是制作一种邀请系统,用户单击用户,他们进入一个列表,一切正常,我可以使用each()获取他们的id,但我需要将其传递jQuery Ajax 到 php 将其发送到数据库以获取通知。这基本上就是我所拥有的:

$(".group-video-create").click(function(){
var url = $(".group-input-url").val();
var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
var checked_url = url.match(exp,"<a href='$1'>$1</a>");
if(checked_url)
{
$("#group-input-names li").each(function(){ // This is the relevant code
var user_id = $(this).attr("id"); // Here too
}); // & here

if(user_id)
{

$.ajax({
type: "POST",
//url: "",
//data: "", //this would be an array of all of the ids, (could be 1, could be 100).
cache: false,
success: function(html){
///Once all invitations have been sent to the database it would then load a new div and hide the previous one.
}
});
}
}
});

如果您想了解我正在努力实现的目标,请转到此处:

http://www.kithell.com/#/video

usr:PhpFreak@yahoo.com通过:phpfreaklogin

它位于群组视频下。 (登录后您应该会自动定向到那里)

最佳答案

您也许可以使用jQuery.serialize捆绑所有表单数据。另外,jQuery.post是使用 jQuery.ajax 执行 POST 请求的一个不错的快捷方式。

一个粗略的例子可能是这样的:

$.post( '/my-ajax-service.php', 
$('#MyForm').serialize(),
function(data, txtStatus, jqXHR) {
//Do stuff
});

关于php - jQueryeach()结果数组到php到数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5836280/

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