Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter Controller with Ajax Request
#3

My general tips (may not be the best, but this is what I usually do):

1) The function in the controller must check if it is an HTTP POST request, using $this->input->post(). You can also check if it is an AJAX request using $this->input->is_ajax_request().
2) The above function will return data in text format - can be html, json or simply plain text. (This will be the response in step 4)
3) JS function you use to execute the controller's function should send HTTP POST, instead of HTTP GET. (I use jQuery .post())
4) The response received from HTTP POST can be processed to can determine whatever action to be done.

Correct me if I'm wrong, I'm still learning.
Reply


Messages In This Thread
RE: CodeIgniter Controller with Ajax Request - by hnz - 01-12-2015, 09:35 AM



Theme © iAndrew 2016 - Forum software by © MyBB