Can't read form values |
If the posted data from your AJAX call has empty values, then ofcourse var_dump($this->input->post(NULL, TRUE)) will be an empty array
Your problem lies in your JavaScript code. For some reason the serialize method is returning an empty form. Find out what could cause that. The problem is not a CI related issue. Try this out, and see what is alerted Code: <!DOCTYPE html> (07-17-2017, 08:26 PM)Paradinight Wrote: console.log($('#agencyForm').serialize()); This is the result from the console: Also I tried this on onclick event( onclick="save(this.form)" ) still the same result. Code: agency_id=&agency_name=&category=&address=&acronym= I also attach the screenshot. (07-18-2017, 02:01 AM)Martin7483 Wrote: If the posted data from your AJAX call has empty values, then ofcourse var_dump($this->input->post(NULL, TRUE)) will be an empty arraySir, Still the same result as the follow the console log. The result is: Code: agency_id=&agency_name=&category=&address=&acronym=
@Paradinight
@Martin7483 I have a working code with this problem by placing the action in the form like this: <form method="POST" action="<?php echo base_url();?>agency/save_c"> But I wanted to use the ajax function and also I wanted to implement the whole CRUD operation. That's why I used my old working CRUD using MODAL. In this case, I don't want to use the MODAL I only want to use the one-page crud.
@Paradinight
@Martin7483 I have a working code for this problem by placing action to the form: <form method="POST" action="<?php echo base_url();?>agency/save"> I have a fully functional CRUD operation using modal but, I wanted not to use modal instead I want to create a one page CRUD operation which only consumes at least 5 input text. That's why I'm changing a little bit code in my old working CRUD.
You are saying that when you post the form without the use of AJAX it works. What does that tell you?
I have taken your form and have tested it.
Code: <form action="#" id="agencyForm" class="form-horizontal"> It worked. The field values are serialized and available in the $_POST array. Maybe a stupid question but what values are you expecting? (07-18-2017, 07:14 AM)Martin7483 Wrote: I have taken your form and have tested it.Sir, It's working when I try to console.log ... When I tried to input random text. I'm trying to figure it out why it doesn't insert in the database. I didn't change my controller & model. Code: agency_id=&agency_name=q&category=q&address=q&acronym=q
|
Welcome Guest, Not a member yet? Register Sign In |