It looks like I can’t make a call outside the current domain name with “AJAX”. But I’m able to call the twitter API (with JSON) in JQuery… aren’t both using the XMLHTTP Object? If so (or not), why am I able to call another domain name with JSON (using JQuery) but not with AJAX ? What’s the difference between Ajax and JSON anyway?
Share
The twitter API uses JSONP, which doesn’t use XMLHTTPRequest, but uses a
<script>tag to include “foreign” javascript. This script then calls a function within your own javascript.Google Maps integration in third-party websites wouldn’t be possible without this “hack” (that’s actually what it is: a hack).
Here’s more info on JSONP:
http://ajaxian.com/archives/jsonp-json-with-padding
or in the wikipedia article on JSON:
http://en.wikipedia.org/wiki/JSON#JSONP