How can I get jsonp to play nice with my class?
- by George Edison
This whole jsonp thing is quite confusing...
Here is what I want to do:
I have a class DataRetriever
The class has a method GetData
GetData makes a jsonp request with the following code:
var new_tag = document.createElement('script');
new_tag.type = 'text/javascript';
new_tag.src = 'http://somesite.com/somemethod?somedata';
// Add the element
var bodyRef = document.getElementsByTagName("body").item(0);
bodyRef.appendChild(new_tag);
Now, the jsonp data from the server somesite.com can call a function in my code with the data. The problem is, how does the data get delivered to the instance of DataRetriever that requested it?
I'm really stuck here.