Welcome Guest, Not a member yet? Register   Sign In
(Solved) jquery ajax base_url()
#1

[eluser]gazza7364[/eluser]
Hi

I'm trying to figure out how to get a url which puts the data into a div without using the full url.

this is a snippet of the code in the controller:-
Code:
$host = 'music/';
  $html = '/artist.html';
  $bio = $host . $data->artist . $html;
                [removed]onLoad=contentDisp(\"$bio\");</scrip

                echo json_encode(array('html' => $output));

Has you can see this is sent by json, which when loaded sends the data to jquery function
contentDisp().

the jquery contentDisp() is as follows:-

Code:
function contentDisp(id)
{
$.ajax({
url : id,
success : function (data) {
$("#bio").html(data);
}
   });
}

The problem i'm having, is the URL which I'm getting back is wrong.

http://localhost/media/music/R.E.M/artist.html which should be http://localhost/music/R.E.M/artist.html.

if I change $host to http://localhost/music/ everything works fine.
Is their a way of writing this without using http://localhost. I have tried using base_url() but that then produces http://localhost/base_url()/music/R.E.M/artist.html..

Any help would be much appreciated.







Theme © iAndrew 2016 - Forum software by © MyBB