Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法使用 ajax 混合选择器和独立数据发送数据,如下所示:
$.ajax({ url:"here.php", data: $("#form :input")+"&"+"id="+id, type:"POST", success: function(res){ $("#something").html(res); } })
我知道我可以单独使用其中任何一个发送数据,但是知道这是否可能对我有很大帮助。任何帮助和建议将不胜感激。
您可以使用serialize()(我想您正在尝试在您的内部发送所有输入值#form)
serialize()
#form
data: $("#form :input").serialize() + "&" + "id=" + id,
您不想发送选择器,而是想在表单中发送输入的值。
var data = $("#form").serialize(); data += "&id=" + id; $.ajax({ url: "foo.php", data: data, ... });