可能重复:
submitting form and variables together through jquery发送通过Ajax的jQuery调用参数服务器
我使用下面的代码通过Ajax将表单数据发送到服务器,jQuery的:
// this is the id of the submit button
$("#submitButtonId").click(function() {
var url = "path/to/your/script.php"; // the script where you handle the form input.
$.ajax({
type: "POST",
url: url,
data: $("#idForm").serialize(), // serializes the form's elements.
success: function(data)
{
alert(data); // show response from the php script.
}
});
return false; // avoid to execute the actual submit of the form.
});
如果我必须发送自己的参数/值,而不是发布表单数据,我该怎么做? 谢谢。