AJAX通过邮寄整个表格提交

时间:2022-09-25 15:51:40

I am trying to simply post an entire form w/o the need to create the url like you would have to in a get call. All of the tutorials I have seen for this for some reason create a parameter URL and send it via the send ability. I want to be able to send a form via the form id or form name, is this possible? The reason is because I will have some submits that can have anywhere from 2 to 1000 checkboxes the user can press (not my choice). Example I looked at mainly is: http://www.captain.at/howto-ajax-form-post-request.php

我试图简单地发布一个完整的表单,而不需要像在get调用中那样创建url。我出于某种原因看到的所有教程都创建了一个参数URL并通过发送功能发送它。我希望能够通过表单ID或表单名称发送表单,这可能吗?原因是我会有一些提交,可以有2到1000个用户可以按的复选框(不是我的选择)。我看的例子主要是:http://www.captain.at/howto-ajax-form-post-request.php

I use a type="button" to do the submit not a onchange or anything like that.

我使用type =“button”来提交而不是onchange或类似的东西。

3 个解决方案

#1


6  

Use jQuery, and it's very easy:

使用jQuery,它非常简单:

$.post("/myactionpage.php",$("#formID").serialize(), function (data) { whatever(); });

#2


1  

If you can use jQuery, the JQuery Form plugin does exactly that.

如果你可以使用jQuery,那么JQuery Form插件就是这样做的。

The jQuery Form Plugin allows you to easily and unobtrusively upgrade HTML forms to use AJAX. The main methods, ajaxForm and ajaxSubmit, gather information from the form element to determine how to manage the submit process.

jQuery Form Plugin允许您轻松且不引人注意地升级HTML表单以使用AJAX。主要方法ajaxForm和ajaxSubmit从表单元素收集信息,以确定如何管理提交过程。

#3


0  

There are multiple ways to do this and you're right, you don't want to use the GET method. You want to use the POST method, which allows you to send all the data in the form. There are too many options to list, but jQuery is a good start. If you don't want to use an external library like jQuery, try checking out a google search on "ajax via post".

有多种方法可以做到这一点你是对的,你不想使用GET方法。您想使用POST方法,它允许您发送表单中的所有数据。列出的选项太多了,但jQuery是一个好的开始。如果您不想使用像jQuery这样的外部库,请尝试在“ajax via post”上查看Google搜索。

#1


6  

Use jQuery, and it's very easy:

使用jQuery,它非常简单:

$.post("/myactionpage.php",$("#formID").serialize(), function (data) { whatever(); });

#2


1  

If you can use jQuery, the JQuery Form plugin does exactly that.

如果你可以使用jQuery,那么JQuery Form插件就是这样做的。

The jQuery Form Plugin allows you to easily and unobtrusively upgrade HTML forms to use AJAX. The main methods, ajaxForm and ajaxSubmit, gather information from the form element to determine how to manage the submit process.

jQuery Form Plugin允许您轻松且不引人注意地升级HTML表单以使用AJAX。主要方法ajaxForm和ajaxSubmit从表单元素收集信息,以确定如何管理提交过程。

#3


0  

There are multiple ways to do this and you're right, you don't want to use the GET method. You want to use the POST method, which allows you to send all the data in the form. There are too many options to list, but jQuery is a good start. If you don't want to use an external library like jQuery, try checking out a google search on "ajax via post".

有多种方法可以做到这一点你是对的,你不想使用GET方法。您想使用POST方法,它允许您发送表单中的所有数据。列出的选项太多了,但jQuery是一个好的开始。如果您不想使用像jQuery这样的外部库,请尝试在“ajax via post”上查看Google搜索。