嗨我在WordPress插件设置 options.php 中使用普通表单提交 . 现在我想在WordPress admin.i中使用基于ajax的表单提交能够使用ajax通过 onsubmit 在表单中进行表单提交
提交
<form id="hhh" onsubmit="return sub();">
<label>FirstName</label>
<input type="text" name="fname" value="">
<label>LastName</label>
<input type"text" name="lname" value="">
<input type="submit" class="button-secondary" value="save" />
</form>
重置
<form method="post">
<input class="button-secondary" name="reset" type="submit" value="Reset" />
</form>
提交的ajax
function sub() {
$.ajax({type:'POST', url: 'options.php', data:$('#hhh').serialize(), success: function(response) {
}});
return false;
}
我可以通过提交使用ajax轻松保存值但是为了重置值我必须调用一个php函数,它将重置表单并且它将添加新的默认值 . 我如何使用ajax实现这一点?谢谢