ajax requests with jquery -- help |
[eluser]bryantAXS[/eluser]
So I'm having some trouble with getting some ajax calls to work using jQuery. I had it working fine previously, but then I made some modifications to my .htacess file and a few more changes and now it seems to not be working. I think it has somthing to do with my .htaccess file - config.php and maybe routing.php? It would be great if someone could explain how ajax calls work with codeigniter and how they are routed to the controller. When my ajax call is fired in the page it looks to this url: http://localhost:888/realm/index.php/sit.../twitterTL It should be connecting to: http://localhost:888/realm/index.php/ajax/twitterTL actual ajax call Code: $.ajax({ Any help and explanation would be greatly appreciated! .htaccess Code: <IfModule mod_rewrite.c> config.php Code: $config['base_url'] = "http://localhost:8888/realm/"; routes.php Code: $route['default_controller'] = "site";
[eluser]bryantAXS[/eluser]
Another thing I noticed, is that when I navigate to the index.php file and it auto loads my Site controller, when i do the ajax call it works fine. The error occurs when i click on the pagination, or when the controllers and functions are actually in the url. Then when i do the ajax call, the existing controller/function parameters stay in the url. I guess this could be a javascript problem, and just the way jQuery handles the url attribute of the ajax object....hmm any help or incite would still be appreciated!
[eluser]iFadey[/eluser]
Recently I faced the same problem. I solved it by replacing the relative path in the ajax call with the absolute path. I mean try this: Code: $.ajax({
[eluser]iFadey[/eluser]
Or try one more thing. Define a base url in the head of your html document like this: Code: <head> Code: $.ajax({ |
Welcome Guest, Not a member yet? Register Sign In |