Welcome Guest, Not a member yet? Register   Sign In
AJAX & CI Controllers
#2

[eluser]boltsabre[/eluser]
Maybe not ideal solution, but could you not just have a "ajax" method inside your controller?

So, the user hits 'delete', ajax calls the 'ajax delete' method in your controller, which in turns calls the model and 'delete' method. Upon successful return from the model you pass the 'deleted id' from your ajax controller back into the view and "fadeOut" the appropriate wrapper div/p/whatever for that record?

There is a way to "lock" controller methods from non-ajax requests, meaning that someone cannot type the url into their browser and call your ajax delete function (which could have devastating impacts if they could)! I've forgotten how to do it (I'm at work and don't have my CI projects infront of me), so you'll have to research this part yourself.
If I remember correctly, there is a line of code that you place inside your config somewhere which checks for a ajax request, and sets a variable (true/false). Then the first thing you do inside your 'ajax' controller is check this variable, if not true, throw up a 404 page and 404 http header, thus preventing people calling it from the direct from the url.

Good luck, post back so we can see what you come up with!


Messages In This Thread
AJAX & CI Controllers - by El Forum - 01-08-2013, 07:01 AM
AJAX & CI Controllers - by El Forum - 01-09-2013, 05:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB