Welcome Guest, Not a member yet? Register   Sign In
URL - HELP
#1

[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: "&lt;? echo base_url(); ?&gt;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.
#2

[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">
#3

[eluser]starbuck[/eluser]
firstly, thx for ur answer. i put slash front of nextcontroller, nothing changes. my problem: in jquery code, url line ( url: “&lt;? echo base_url(); ?&gt;/nextcontroller/votehome”,) links previous url (/nextcontroller/index/id/2)
#4

[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'
and not use PHP.
#5

[eluser]starbuck[/eluser]
I forgot to put slash front of js file path. Thx for ur helping Smile




Theme © iAndrew 2016 - Forum software by © MyBB