在 jQuery Ajax 函数中将整个表单作为数据传递 [英] Pass entire form as data in jQuery Ajax function

查看:32
本文介绍了在 jQuery Ajax 函数中将整个表单作为数据传递的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 jQuery ajax 函数,想提交整个表单作为发布数据.我们会不断更新表单,因此不断更新应在请求中发送的表单输入会变得很乏味.

I have a jQuery ajax function and would like to submit an entire form as post data. We are constantly updating the form so it becomes tedious to constantly update the form inputs that should be sent in the request.

推荐答案

有一个函数可以做到这一点:

There's a function that does exactly this:

http://api.jquery.com/serialize/

var data = $('form').serialize();
$.post('url', data);

这篇关于在 jQuery Ajax 函数中将整个表单作为数据传递的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆