我在php文件中的HTML表单看起来像这样。
$userid=$_GET["userid"];
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="text" name="username" />
--------more inputs
<input type="submit" name="submit" />
</form>
我的ajax代码看起来像这样;
jQuery(document).ready(function($) {
$(".respond").submit(function(event){
var $form = $(this);
var $inputs = $form.find("input, select, button, textarea");
var serializedData = $form.serialize();
$inputs.prop("disabled", true);
request = $.ajax({
url: "/admin/index.php",
type: "post",
data: serializedData,
datetype:JSON
});
request.done(function (response, textStatus, jqXHR){
console.log(response);
});
request.fail(function (jqXHR, textStatus, errorThrown){
console.error(
"The following error occured: "+
textStatus, errorThrown
);
});
request.always(function () {
$inputs.prop("disabled", false);
});
event.preventDefault();
});
});
现在如何发送$user_id
,表单提交按钮被点击信息以及通过ajax序列化数据