> I want to make a remote request to a different server than 
> the current page is hosted on, in order to get JSON data 
> (padded with a callback).
> 
> This is typically handled by inserting <script> elements on 
> the current page with the src as the remote URL, (Right?), 
> but I couldn't find an easy way to do this on jQuery. 
> I looked at $.getScript; but it's more a way to use 
> XmlHTTPConnect(), and eval the results as a script.
> 
> Does anyone have any ideas as to how one may go about this?

The code to do this is really simple. In fact, the very first jQuery plugin
was this one that I wrote a year ago:

http://mg.to/2006/01/25/json-for-jquery

Be sure to read the comments for some IE memory issues and other notes.
Also, the code uses "(new Date).getTime()" to generate a unique callback
function name. This was a really bad idea! Besides not always being unique
(if you make two JSON calls in quick succession), it wreaks havoc with
caching, since each JSON call will have a different URL. The code I'm
currently using takes a callback function name as an argument to the
$.json() call.

A server-side proxy like the one Jake posted is also a great way to do this,
if that approach works for you.

-Mike


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to