ohdang888 Posted May 21, 2009 Share Posted May 21, 2009 i'm just curious how systems like google analytics works... like, how does javascript interact with another server? I know there's ajax, but i've always heard its not safe to use ajax across domains Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted May 21, 2009 Share Posted May 21, 2009 By default browser's don't allow cross-domain JavaScript. I forget how, but there is a way that is supported by the JavaScript language to allow cross-domain scripting. It could also be the case that you install JavaScript on your page that talks to a page on your domain and behind the scenes this page talks to Google or whoever. + You embed ad in your page with JavaScript attached + User clicks ad, JavaScript talks to ad.php on your domain. + ad.php then sends web service request behind the scenes to a third party. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 21, 2009 Share Posted May 21, 2009 What do you mean not safe? It's not even possible. However, you can call a JavaScript file that works as a PHP file. Quote Link to comment Share on other sites More sharing options...
ohdang888 Posted May 21, 2009 Author Share Posted May 21, 2009 What do you mean not safe? It's not even possible. However, you can call a JavaScript file that works as a PHP file. how do you do that? thanks! It could also be the case that you install JavaScript on your page that talks to a page on your domain and behind the scenes this page talks to Google or whoever. well google analytical doesn't put a file on your site yet it still interacts with another server with javascript Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted May 21, 2009 Share Posted May 21, 2009 It's not even possible. From my recollection, it is possible but both domains have to collaborate with each other. I believe I read how to do this in O'Reilly's Complete JavaScript Reference. http://jszen.blogspot.com/2005/03/cross-domain-security-woes.html Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 21, 2009 Share Posted May 21, 2009 I meant it's not possible in response to cross-domain AJAX. Quote Link to comment Share on other sites More sharing options...
RichardRotterdam Posted May 22, 2009 Share Posted May 22, 2009 It's not even possible. From my recollection, it is possible but both domains have to collaborate with each other. I believe I read how to do this in O'Reilly's Complete JavaScript Reference. http://jszen.blogspot.com/2005/03/cross-domain-security-woes.html It's also possible with a workaround called jsonp(json with padding). Your serverside script does have to give the output in a certain way. Twitter offers this service so thats how I found out about it.Have a look on the following articles for more info. http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/ http://en.wikipedia.org/wiki/JSON#JSONP http://docs.jquery.com/Release:jQuery_1.2/Ajax#Cross-Domain_getJSON_.28using_JSONP.29 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.