Welcome Guest, Not a member yet? Register   Sign In
Checking Ajax POST request
#1

[eluser]HooJee[/eluser]
Hi Guys

If I am making a POST request via AJAX how can I check whether the POST request was made in CI ? Usually The following works for a page refresh form submittion but not for an ajax request since it requires the submittion button name:

Code:
if($this->input->post('addBtn')) {
  // do something
}
#2

[eluser]umefarooq[/eluser]
can you post javascript how you are posting your data to CI.
#3

[eluser]Krzemo[/eluser]
You get Ajax post value exactly the same way as regular form. Firefox and Firebug may help debuging.
#4

[eluser]jdfwarrior[/eluser]
[quote author="HooJee" date="1249579979"]Hi Guys

If I am making a POST request via AJAX how can I check whether the POST request was made in CI ? Usually The following works for a page refresh form submittion but not for an ajax request since it requires the submittion button name:

Code:
if($this->input->post('addBtn')) {
  // do something
}
[/quote]

Not understanding the question. You want to be able to check and see if a CI based system made the post? Or are you trying to find out if the post to CI worked? If your using jQuery, I made a quick post one day about posting to CI using jQuery. See my sig.
#5

[eluser]Spicer[/eluser]
I have used this solutions in the past.

http://snipplr.com/view/1060/check-for-ajax-request/

There are a few different ways to do it, but from my understanding you want to do something like this.

Code:
if(isajax())
  $this->load->view(ajax-view);
else
  $this->load->view(noajax-view);




Theme © iAndrew 2016 - Forum software by © MyBB