Welcome Guest, Not a member yet? Register   Sign In
Using controller actions using jQuery AJAX?
#4

[eluser]Colin Williams[/eluser]
Quote:But… I want this controller to be called by AJAX. So the user doesn’t leave the page at all. It’ll call the same ‘bookmark/member/32’ but will pass back a ‘true’ statement (for example) which I can then use to update the list instead.

That's where checking the HTTP_X_REQUESTED_WITH server variable comes in. You can use this to determine what you output from the method, either a full page (non-ajax) or just a simple string like 'true'

Code:
if ($this->input->server('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest')
{
  print 'true';
}
else
{
  $this->load->view($view, $data);
}


Messages In This Thread
Using controller actions using jQuery AJAX? - by El Forum - 02-09-2009, 06:39 AM
Using controller actions using jQuery AJAX? - by El Forum - 02-09-2009, 06:51 AM
Using controller actions using jQuery AJAX? - by El Forum - 02-09-2009, 07:04 AM
Using controller actions using jQuery AJAX? - by El Forum - 02-09-2009, 07:08 AM
Using controller actions using jQuery AJAX? - by El Forum - 02-09-2009, 07:13 AM
Using controller actions using jQuery AJAX? - by El Forum - 02-09-2009, 07:26 AM
Using controller actions using jQuery AJAX? - by El Forum - 02-09-2009, 07:28 AM
Using controller actions using jQuery AJAX? - by El Forum - 02-09-2009, 07:32 AM
Using controller actions using jQuery AJAX? - by El Forum - 02-09-2009, 07:37 AM



Theme © iAndrew 2016 - Forum software by © MyBB