且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

jQuery AJAX 提交表单

更新时间:2022-12-11 13:35:36

您可以使用 Ajax 表单插件 或 jQuery 序列化函数.

You can use the ajaxForm/ajaxSubmit functions from Ajax Form Plugin or the jQuery serialize function.

AjaxForm:

$("#theForm").ajaxForm({url: 'server.php', type: 'post'})

$("#theForm").ajaxSubmit({url: 'server.php', type: 'post'})

ajaxForm 将在提交按钮被按下时发送.ajaxSubmit 立即发送.

ajaxForm will send when the submit button is pressed. ajaxSubmit sends immediately.

序列化:

$.get('server.php?' + $('#theForm').serialize())

$.post('server.php', $('#theForm').serialize())

AJAX 序列化文档在这里.