Use jQuery.ajax (or it's wrapper functions such as jQuery.getJSON) to cover
all cross-browser issues.
And as indirectly suggested above. JSONP is the solution for cross-domain
scripting.
What it means is that that source (in this case toolserver) has a URL
parameter (say &callback=), the script then returns the folllowing:
callback({ my: 'data' });
This is the exception / work-around to same origin policiy as it can be done
through a simple script tag because there is a callback.
This callback function can be dynamic and generated on the fly with jQuery
by using a ? as callback
Example:
http://toolserver.org/~krinkle/tmp/jsonp_example.php?callback=myFunc
jQuery.getJSON( '
http://toolserver.org/~krinkle/tmp/jsonp_example.php?callback=?'#39;,
function(data){
alert(data.hello); }
);
2011/2/1 Daniel Kinzler <daniel(a)brightbyte.de>
Hi all!
what's the best way to get around the same original policy to fetch data
from
the toolserver with a XMLHTTPRequest in a Wikipedia gadget? Is there a best
practice, a nice and easy, generally usable method? what would it take to
make one?
I know that some gadgets have been doing this, but I also know that it's a
bit
tricky. I think a general solution to this, documented somewhere, would
make
life a lot easier... does something like this exist? if not, why not?
-- daniel
PS: while i'm at it, is there a wrapper function for XMLHTTPRequest in the
standard MEdiaWiki JS? I don't want to re-invent a sucky wheel :)
_______________________________________________
Toolserver-l mailing list (Toolserver-l(a)lists.wikimedia.org)
https://lists.wikimedia.org/mailman/listinfo/toolserver-l
Posting guidelines for this list:
https://wiki.toolserver.org/view/Mailing_list_etiquette