本文介绍了使用AJAX和jQuery提交表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
看起来这应该是内置到jQuery的,而不需要超过code几行东西,但我找不到简单的解决方案。我说,我有一个HTML表单:
It seems like this should be something built into jQuery without the need for more than a few lines of code, but I can't find the "simple" solution. Say, I have an HTML form:
<form method="get" action="page.html">
<input type="hidden" name="field1" value="value1" />
<input type="hidden" name="field2" value="value2" />
<select name="status">
<option value=""></option>
<option value="good">Good</option>
<option value="bad">Bad</option>
</select>
</form>
当有人改变了选择字段,我想用ajax来更新数据库提交表单。我以为会有某种方式做,而无需手动创建值/属性下,只是给他们,这样的:
When someone changes the select field, I would like to submit the form using ajax to update the database. I thought there would be some way to do the following without manually creating the values/attributes, just send them all, like:
$("select").change(function(){
$.get("page.html?" + serializeForm());
});
我在想什么?
What am I missing?
推荐答案
这是什么结束了工作。
$("select").change(function(){
$.get("/page.html?" + $(this).parent("form").find(":input").serialize());
});
这篇关于使用AJAX和jQuery提交表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!