Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop the current domain from being prepended to the URL during jQuery AJAX call [duplicate]

Im trying to make an ajax call using an absolute url. But the url is automatically being prepended with the current domain and hence giving me a 404. How can I stop the current domain from prepending to the URL.

$.ajax({ type: "GET", url: "www.xxxx.org" + path + ".zzzz.json",

            . 
            .
            // rest of the code }

here path is /etc/xxx/yyy/etc

The error I'm getting is: GET http://yyyyy.xxx.org/www.xxx.org/etc/xxx/yyy/zzzz.json 404.

If anyone has any idea about solving this problem, please help. Thank you.

like image 730
midhunsezhi Avatar asked Oct 17 '25 17:10

midhunsezhi


1 Answers

URLs without a leading scheme are treated as relative URLs from the origin of current page. (This is the same behavior for the values in <a href="..."> links.)

You must use a scheme, e.g., http://www.xxxx.com/... instead of www.xxxx.com/...

like image 192
apsillers Avatar answered Oct 19 '25 11:10

apsillers