作者:爱他让我心痛_830 | 来源:互联网 | 2023-05-16 09:48
ImtryingtoAJAXIFYaformwithoutusingjQueryplugins.Whatistheprocessformakingthishappe
I'm trying to AJAXIFY a form without using jQuery plugins. What is the process for making this happen. I have my form. What should I set the action to? What should the header script be? Keep in mind that I do not want to use any plugins. I just need a basic algorithm for ajaxifying forms using jquery.
我试图在不使用jQuery插件的情况下对表单进行AJAXIFY。实现这一目标的过程是什么?我有我的表格。我应该将动作设置为什么?标题脚本应该是什么?请记住,我不想使用任何插件。我只需要一个基本算法来使用jquery来调整表单。
3 个解决方案
2
The simplest method is to use the $.load() method.
最简单的方法是使用$ .load()方法。
$.load(action, data, callback)
$ .load(动作,数据,回调)
The action could be a PHP script, ASP page, or simply another web page. If the data is null, it performs a GET. Otherwise, it performs a POST. The callback method is executed when the method is complete (not necessarily successful).
该操作可以是PHP脚本,ASP页面,也可以是其他网页。如果数据为null,则执行GET。否则,它执行POST。当方法完成时(不一定成功)执行回调方法。
http://docs.jquery.com/Ajax/load
http://docs.jquery.com/Ajax/load
For example:
例如:
$.load("scripts/processOrder.php", { item: itemID, quantity: ordered }, function {
window.location.href = "orderComplete.htm";
});
When the form is submitted, the processOrder script is executed with the itemID and ordered arguments passed as data. When the script is finished, the browser navigate to the orderComplete page for additional processing or status display.
提交表单时,将使用itemID和作为数据传递的有序参数执行processOrder脚本。脚本完成后,浏览器将导航到orderComplete页面以进行其他处理或状态显示。
If you wish to take more control over the Ajaxification, you can use the $.get, $.post, or $.ajax methods.
如果您希望更多地控制Ajaxification,可以使用$ .get,$ .post或$ .ajax方法。