Welcome Guest, Not a member yet? Register   Sign In
controller functions that are only accessible to jquery or ajax
#1

[eluser]xeroblast[/eluser]
as i was reading this thread : http://ellislab.com/forums/viewthread/229428/ .. a question pops in my mind..

if making function in controller to be private and not be accessible in the URL. is there a way to send data via ajax and its URL is not accessible by the browser but only ajax?

i tried making a private function but ajax cant send the data to the URL i give.
#2

[eluser]Mirge[/eluser]
Keep your function accessible so that you can query it via AJAX, and in the controller itself, test if it's an ajax call via is_ajax_request(). See manual here, very bottom: http://ellislab.com/codeigniter/user-gui...input.html

An example might be something like:

Code:
public function get_cities()
{
     if(! $this->input->is_ajax_request())
          show_404();

     // Otherwise, proceed as usual!
}
#3

[eluser]xeroblast[/eluser]
this is what im looking for..
#4

[eluser]Mirge[/eluser]
Happy to help.




Theme © iAndrew 2016 - Forum software by © MyBB