简体   繁体   English

更新表单而不加载或重新加载页面

[英]update a form and not load or reload page

I have a simple command: 我有一个简单的命令:

<?php echo form_open("sales/add",array('id'=>'add_item_form')); ?>

How can I make this command so it just updates the form, without reload or redirection. 我如何制作此命令,使其仅更新表单,而无需重新加载或重定向。 I dont even need to see the form. 我什至不需要看表格。 I have tried all sorts of methods, but wondering if there is something simple here I am missing. 我尝试了各种方法,但想知道这里是否缺少一些简单的东西。 I just need to post the data. 我只需要发布数据。 This is what is outputted by codeigniter. 这是codeigniter输出的。

<form action="http://127.0.0.1/index.php/sales/add" method="post" id="add_item_form">
    <label id="item_label" for="item">
</form>

I have tried jquery but still does not work. 我已经尝试过jQuery,但仍然无法正常工作。 Any help would be greatly appreciated. 任何帮助将不胜感激。

您可以使用iframe或xml http请求( ajax

You absolutely need jquery ajax function to do that. 您绝对需要jquery ajax函数来做到这一点。 Maybe you have tried different jquery function. 也许您尝试了不同的jquery函数。 Check this out: 看一下这个:

http://api.jquery.com/jQuery.post/

There are some examples in that link you can look at. 您可以查看该链接中的一些示例。

Do you know the path of your controller? 您知道控制器的路径吗? Then you can use jQuery to do that. 然后,您可以使用jQuery来做到这一点。 Check this plugin: http://jquery.malsup.com/form/ 检查此插件: http : //jquery.malsup.com/form/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM