Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get data from external URL with jquery

I have an external URL that gets parameters and prints a result like this: {"result": "not_avail"}

I'm trying to use jQuery to get the result like this:

$.get("http://www.thepage.html?id=2&name=david", function(data){
    alert("Data Loaded: " + data);
});

But nothing happens, I'm not getting an alert and not getting any errors in firebug. How can I solve this?

like image 431
lior r Avatar asked Dec 04 '25 18:12

lior r


1 Answers

Due to browser security restrictions, most "Ajax" requests are subject to the same origin policy; the request can not successfully retrieve data from a different domain, subdomain, or protocol.

from official documentation

Try to use relative path tou your script (on same domain)

like image 161
Arthur Halma Avatar answered Dec 06 '25 09:12

Arthur Halma