简体   繁体   中英

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.

<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. Any help would be greatly appreciated.

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

You absolutely need jquery ajax function to do that. Maybe you have tried different jquery function. 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. Check this plugin: http://jquery.malsup.com/form/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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