I am trying to get the href value of an anchor tag using jquery, instead of getting the absolute url, jquery returns just the url without the file part: This is what i mean:
My Html/php
$url = "http://localhost/mysite/assets/data.txt";
<a class='view-chart' href="<?php echo $url?>">View Chart</a>
My jQuery Code:
var url = $('a.view-chart').attr('href');
alert(url);
I get this on the alert:
http://localhost/mysite/assets/
but when I view source on the browser, I see
http://localhost/mysite/assets/data.txt
But if I do:
<a class='view-chart' href="http://localhost/mysite/assets/data.txt">View Chart</a>
I get the correct alert message i.e:
http://localhost/mysite/assets/data.txt
Try this. It worked for me in localhost