Welcome Guest, Not a member yet? Register   Sign In
codeigniter and ajax?
#1

[eluser]bennyhill[/eluser]
I have a edit product page where a user can edit the product information for a given product. How would I allow the user to clear out the existing image or pdf from the database without reloading the page and losing the other edits they made (i.e product description text)? Would I use ajax for this?
#2

[eluser]TheFuzzy0ne[/eluser]
Yes. As far as I know, Ajax is the only way to make a request to a server without refreshing the page.
#3

[eluser]bennyhill[/eluser]
is there any tutorials on making ajax calls from codeigniter?
#4

[eluser]TheFuzzy0ne[/eluser]
Probably not, but it's not that difficult. You include the script from within your view(s), and then you the put this into your constants.php:
Code:
define('IS_AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')

Then you can check if the incoming request is an ajax request, from within your controller like this:
Code:
if (IS_AJAX)
{
    # Do something Ajaxy
}
else
{
    # Do something non-Ajaxy
}
#5

[eluser]Rob Steele[/eluser]
wow i give you props on this, i'm keeping that little segment for myself too
#6

[eluser]MeanStudios[/eluser]
Dude, TheFuzzyOne, great piece of code there Smile. Definitely saving that snippet Big Grin. Thanks!




Theme © iAndrew 2016 - Forum software by © MyBB