i tried to work with jquery and forms combining with CI but i couldn’t get it work… i am still a newbie in jquery so i tried to searc for good toturials, but all i found was scripts…
what i want to do is to send a form through jquery and work with the data with CI.
There are two ways to submit forms with jQuery, GET and POST. Dont bother with GET as it doesnt get along with CI very well, use POST. Shouldnt matter if you use a normal page request or use AJAX, POST will appear in CI the same.
If you REALLY need to use a URL to send your values, you can so it like this:
There are two ways to submit forms with jQuery, GET and POST. Dont bother with GET as it doesnt get along with CI very well, use POST. Shouldnt matter if you use a normal page request or use AJAX, POST will appear in CI the same.
If you REALLY need to use a URL to send your values, you can so it like this:
You are sending it the POST key of “comment” in your Javascript, but in your PHP you are looking for “content”. Also, try using $this->input->post(’comment’) instead of $_REQUEST as I think CI MIGHT kill that variable just like GET as its even more insecure.
You also are using $(this).html() which is incorrect, as you would be sending the inner HTML of the submit button they just clicked, which is clearly wrong. You want to send $("input#comment_box").text() or .html() instead.
There is no reason for your “e” parameter in the function call, and really you should do some checking in both JS and PHP to see if it worked. If the data is invalid then return a status header ( I use the following code to see if it worked or not, 404 is the wrong status but I dont know a better one).
function delete_payment($id = 0) { $this->load->helper('ajax'); if(isAjax()): if($this->invoices_model->deleteInvoicePayment($id)): $this->output->set_header('HTTP/1.1 200 OK'); // Worked fine
Just play the debug game, echo it in the controller, print_r($_POST), keep going until you find where its showing as NULL then you have your answer.
The code you posted cant be all your controller, as you have the code <?=$this->obj->validation->content?> in your view, which would suggest you are validating this somewhere and I see no validation here.
Just play the debug game, echo it in the controller, print_r($_POST), keep going until you find where its showing as NULL then you have your answer.
The code you posted cant be all your controller, as you have the code <?=$this->obj->validation->content?> in your view, which would suggest you are validating this somewhere and I see no validation here.
i can’t echo anything in the controoler because it right away going to the view file from the ajax.
and u don’t see the validation call, cuz i am doing something like this:
i have my controller, which there i load my libraries and in there i have my own comments library.
in the comments library i have some functions that includes printing the comment form.
from my view i call to this printing function.
without the ajax it works perfect but when i pumped it up with ajax, it started to mess up a little bit… S:
Force your If check to make it think its not via isAjax. Test that post gets there alright, if it does get there then its something else.
If you can debug it yourself with clever quickswitches then try using Firebug as that will show you exactly what is coming back from Ajax requests, that way you can output anything and the AJAX responce will help you debug.