Submit form using jquery ajax in codeigniter
Listing 4: This consists of the html and PHP code div id"loadplace?php echo msg_id;?
' span class"ui-icon ui-icon-info" '.msg.
Create a getUserDetails method to fetch ajax post username user detail from users table submit and return an Array to the controller.
Controller, navigate to application/controllers/ directory and create a p file.
Here using are the descriptions for jquery what those options stands for.Make ajax call either from the view or external script file.And here we'll see how to use ajax in code igniter for form submission.Read How to post form data submit using Angularjs and codeigniter?After creating view, now lets talk about form Ajax post method, here I created.Figure 3 Multipart form page Listing 8: Support for all browsers The code defined in Listing 7 may not always support all browsers, mainly older ones.Completed Code?php defined basepath OR exit codeigniter No direct script access allowed class User ajax extends CI_Controller public function index / load base_url / load view public function userDetails / post data postData this- input- post /load model / get data data echo json_encode(data.All things are set up and we can start setting up our form.
Then you should include jquery library and episode add js snippet which will collect the form live data (in our case it's just email id) and submit the form via jquery's ajax method.
Please stay tuned to patch get awesome tips.
Forms are largely used on a number of websites to collect data that may be dock required to be obtained from a user.