Can't get URI class and jquery Ajax resquest working right. - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Can't get URI class and jquery Ajax resquest working right. (/showthread.php?tid=27112) |
Can't get URI class and jquery Ajax resquest working right. - El Forum - 02-01-2010 [eluser]chefnelone[/eluser] I'm using ajax request (with jquery). Until now everything went fine. But I have a problem when I use the URI class. When using segments in the url the ajax request doesn't work. If I run this code there's no problem in controller site.php Code: function products(){ in the view views/backend/products.php Code: <form class="updateProduct" action="" method="post"> Code: $(document).ready(function() { EVETHING WORKS FINE But if I change this: Code: $data['product_id'] = '10'; Code: $data['product_id'] = $this->uri->segment(3); And load the page at: I load the page at: http://locallhost/ci/site/products/10 I doesn't work. I don't know how to solve it BUT I know the problem is JUST this line. Can't get URI class and jquery Ajax resquest working right. - El Forum - 02-01-2010 [eluser]danmontgomery[/eluser] Possible that you're trying to load the URI class after it's already been loaded? IIRC loading it twice empties the uri_segments. Why not just pass the ID into the function? Code: function products($product_id) { Can't get URI class and jquery Ajax resquest working right. - El Forum - 02-01-2010 [eluser]chefnelone[/eluser] [quote author="noctrum" date="1265068053"]Possible that you're trying to load the URI class after it's already been loaded? IIRC loading it twice empties the uri_segments. Why not just pass the ID into the function? Code: function products($product_id) { I tried and din't work. but it was useful to see that it doesn't work even if I take out the line BUT add a segment to the url: Code: $data['product_id'] = $this->uri->segment(3); It seems that it doesn't work if I add a segment to the url like (even if I don't use the uri class): http://locallhost/ci/site/products/10 //DOESN'T WORK http://locallhost/ci/site/products // WORKS FINE Can't get URI class and jquery Ajax resquest working right. - El Forum - 02-01-2010 [eluser]chefnelone[/eluser] I solved it. using this Code: $.post('http://locallhost/ci/site/update_product' , $(this).serialize() , function(html){}); instead of: Code: $.post('../site/update_product' , $(this).serialize() , function(html){}); Can't get URI class and jquery Ajax resquest working right. - El Forum - 02-01-2010 [eluser]danmontgomery[/eluser] Then you have a routing problem... index.php/[controller]/[function]/[parameter] is basic CI functionality that works with no customization Can't get URI class and jquery Ajax resquest working right. - El Forum - 02-01-2010 [eluser]chefnelone[/eluser] [quote author="noctrum" date="1265071867"]Then you have a routing problem... index.php/[controller]/[function]/[parameter] is basic CI functionality that works with no customization[/quote] how can I check on this? |