I'm trying hard here to figure out how to do a JSONP request, but everywhere I look for reference material is all jQuery examples. I can read the jQuery source, but I wanted a clean and simple example. I'm building a library for something and I dont want to include jQuery, so please, no jQuery $.getJSON. I know how to do use that.
My server spits out the normal callback({"foo":"bar"}) response with a content-type: application/json; charset=utf-8 MIME.
So if I put in a script tag like (using Twitter since I KNOW their API works):
<script src="http://twitter.com/users/oscargodson.json?callback=test"></script>
Or dynamically. Either works and I get the JSON, its the next step I can't figure out.
If I do just console.log(test) after the script loads I get: Uncaught ReferenceError: test is not defined
Why? How, after i get the response from the server, do I then pass that to myself? On my own server if i do callback = {"foo":"bar"} callback works and returns an object, but not the way above. How come? Ive only used AJAX libraries to do this, but for this project I need to code it myself :)