Reputation: 355
Ajax response I am getting is always empty! Interestingly, if I copy paste that URL in browser, I do get a proper html snippet (test ad) back. I guess this is related to some cross-site call stuff. Need some help/pointers as response is not json. Its html code.
Please look at the code - http://pastie.org/1120352
Upvotes: 1
Views: 172
Reputation: 36373
Also, try adding type attribute.
$(document).ready(function (){
$.get(
url: url,
data: {},
callback: function (d) {
alert(d);
},
type: 'json' \\ or whatever the call is returning
);
});
Upvotes: 0
Reputation: 9092
Also, it seems like your code has an extra closing bracket and parentesis.
$(document).ready(function () {
$.get(url,{}, function (d) {
alert(d);
}
});
});
Upvotes: 0
Reputation: 14123
Yes, the problem is most likely cross-domain restrictions.
Can you state whether the web page itself is on the same domain and subdomain as the URL you are requesting (http://ads.admarvel.com/
)?
If you are not on the same domain then you will need to make a request to a proxy script to grab the data.
Upvotes: 1
Reputation: 382666
It looks you are fetching data from some different host.
You need to have a look at Same Origin Policy:
In computing, the same origin policy is an important security concept for a number of browser-side programming languages, such as JavaScript. The policy permits scripts running on pages originating from the same site to access each other's methods and properties with no specific restrictions, but prevents access to most methods and properties across pages on different sites.
For you to be able to get data, it has to be:
Same protocol and host
You need to implement JSONP to workaround it.
Upvotes: 1