![]() |
URL - HELP - 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: URL - HELP (/showthread.php?tid=59931) |
URL - HELP - El Forum - 12-11-2013 [eluser]starbuck[/eluser] Hi, İ am fresh in Codeigniter. While i'm developing a facebook, i got a trouble. In default controller derby->method index->view page: <a href="nextcontroller/index/id/2"> When i clicked link,new page loads. In new view pagei i have another link. It's href part is empty. When i click it, jquery works. $(function() { $(".vote").click(function() { var id = $(this).attr("id"); var name = $(this).attr("name"); var derby_team = $(this).attr("rev"); var dataString = 'id='+ id + '&derby;_team=' + derby_team ; var parent = $(this); if(name=='up') { $(this).fadeIn(200).html('<img src="img/dot.gif" align="absmiddle">'); $.ajax({ type: "POST", dataType: 'json', url: "<? echo base_url(); ?>nextcontroller/votehome", data: dataString, cache: false, success: function(html) { var vote_home = html.home; parent.html(vote_home); var vote_away = 100 - vote_home; $("#away").text(vote_away); } }); } My problem is: exampe.com/nextcontroller/method2 (I wanted that) but i have that exampe.com/nextcontroller/index/id/2/nextcontroller/votehome It adds previous url to new. URL - HELP - El Forum - 12-11-2013 [eluser]CroNiX[/eluser] Probably because you are using relative URLs. Try putting a slash in front of nextcontroller so it starts from the root of your site, like Code: <a href="/nextcontroller/method2"> URL - HELP - El Forum - 12-11-2013 [eluser]starbuck[/eluser] firstly, thx for ur answer. i put slash front of nextcontroller, nothing changes. my problem: in jquery code, url line ( url: “<? echo base_url(); ?>/nextcontroller/votehome”,) links previous url (/nextcontroller/index/id/2) URL - HELP - El Forum - 12-11-2013 [eluser]CroNiX[/eluser] Is your javascript in its own external js file, or is it contained in a php view file? In jquery, try using using: Code: url: '/nextcontroller/votehome' URL - HELP - El Forum - 12-12-2013 [eluser]starbuck[/eluser] I forgot to put slash front of js file path. Thx for ur helping ![]() |