How to do Cross Domain Request?
in Using jQuery
•
8 years ago
I have 2 questions really.
I need to return a message returned by an API and display this message on my own website. I'm pretty new at this so I'm struggling a bit.
http://cloudandproud.cloudapp.net/api/values?id=42
My first confusion is that when I run the command through CURL the it tells me the content-type is JSON, however when you go to the link above, its posted as an XML file, if it was an XML file or a JSON file, I think I would know what to do so I am stuck at with what I need to do next in my code.
$.ajax({ type: 'GET', dataType: 'jsonp', url: 'http://cloudandproud.cloudapp.net/api/values?id=42', success: function(){ }, error: function(){ console.log("could not retrieve data"); } });
The 2nd issue is the whole accessing files across different domains. I understand why you can't access a file from different domain like you would if was from the same server. But have had trouble understanding how you get past these with JSONP and such.
Any help would be greatly appreciated, as Im getting pretty fed up with it all.
Thanks in advance
1