www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > JavaScript

    JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...)

    Reply
     
    Thread Tools Rate Thread Display Modes
      #1  
    Old 03-11-2010, 01:13 PM
    vitasnik vitasnik is offline
    Registered User
     
    Join Date: Feb 2006
    Posts: 13
    Question Ajax cross-domain calls

    I'm trying to write a script that will be loaded from one server into a website on another server. This script is trying to talk (ajax) to the server that it comes from but I'm getting "Access Denied" errors.

    I'm well aware that cross-domain calls are not allowed for security reasons so my question is how does Google Analytics work because essentially thats what I'm trying to accomplish.

    I can embed a Google Analytics script into my website and it'll gather data and send it back to Google. Wondering how they do it?

    Help is much appreciated.

    Nik
    Reply With Quote
      #2  
    Old 03-11-2010, 04:41 PM
    rnd me's Avatar
    rnd me rnd me is offline
    working on the chain...
     
    Join Date: Jul 2008
    Location: urbana, il
    Posts: 1,793
    just don't use XMLHttpRequest, and you'll be fine; javascript can come from any domain.
    Reply With Quote
      #3  
    Old 03-11-2010, 10:11 PM
    vitasnik vitasnik is offline
    Registered User
     
    Join Date: Feb 2006
    Posts: 13
    what should I use instead of XMLHttpRequest?
    Reply With Quote
      #4  
    Old 03-11-2010, 10:48 PM
    rnd me's Avatar
    rnd me rnd me is offline
    working on the chain...
     
    Join Date: Jul 2008
    Location: urbana, il
    Posts: 1,793
    Quote:
    Originally Posted by vitasnik View Post
    what should I use instead of XMLHttpRequest?
    two options:
    Code:
    function ping(paf){
       var i = new Image();
       i.src=paf;
    }//end ping
    
    
    function addScript(u){
       var sc2=document.createElement('script'); sc2.src=u; 
        return  document.getElementsByTagName('head')[0].appendChild(sc2);
    }
    Reply With Quote
      #5  
    Old 03-12-2010, 08:55 AM
    vitasnik vitasnik is offline
    Registered User
     
    Join Date: Feb 2006
    Posts: 13
    Hahaha, brilliant...and so simple.

    Thanks a million!

    Much appreciated.

    Nik
    Reply With Quote
    Reply

    Bookmarks

    Tags
    ajax, cross-domain


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 01:07 PM.



    Acceptable Use Policy

    Internet.com
    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.