ajax request with jquery problem - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: ajax request with jquery problem (/showthread.php?tid=52100) |
ajax request with jquery problem - El Forum - 05-29-2012 [eluser]jon29[/eluser] hi I'm having real problems getting jquery ajax requests to work, problem seem to be that the request doesn't go to the correct controller method and either returns with all the content for my 404 page or returns the content for the page you are already viewing, putting an extra / before the admin/process didn't help, have posted a simple example have tried a few ajax scripts that are working fine outside codeigniter and all seem to have the same problem any ideas very much appreciated many thanks this is the js file Code: $(document).ready(function(){ and this is the controller Code: function process() { ajax request with jquery problem - El Forum - 05-29-2012 [eluser]CroNiX[/eluser] Because you're using a relative URL. And if you're not using htaccess to process requests without index.php in them, you need to add that too. ajax request with jquery problem - El Forum - 05-29-2012 [eluser]jon29[/eluser] yeah that makes sense, thanks !! ajax request with jquery problem - El Forum - 05-29-2012 [eluser]InsiteFX[/eluser] Replace $ with s in script tags. Code: <head> Now you can use base_url and site_url in your jQuery. Code: $.post(base_url+"admin/process", {'item' : item}, function(Data){ |