CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 3 of 3

Thread: Ajax from a different domain

  1. #1
    Join Date
    Feb 2004
    Bristol, England

    Ajax from a different domain


    I have an ajax script that I would like to use to retrieve a password hint from a database.

    Both the ajax script and the php retrieval script are stored on the same domain (we'll call it, but the ajax script runs on another domain (

    All the scripts are working fine, individually, but when I try to integrate them, I'm getting a ready state of 4, but an HTTP status of 0. I've traced the code flow and the retrieval script is being called by the ajax script OK and it's echoing all the right stuff, but it's just not getting back to calling ajax routine.

    I've read that an ajax routine can only call a script that resides on the same domain that it runs on. Is this correct and, if so, does anyone know of a work around, because I really need to be able to store the ajax script on domain1 and run it on domain2?

    If not, then can anyone suggest why I'm getting an HTTP status of 0, when all the individual components are working fine?

    - your quick and easy, yet powerful solution for managing your
    membership site sales, downloads and affiliates.

  2. #2
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002

    Re: Ajax from a different domain

    You have read correctly. JavaScript cannot violate cross domain. That would be a major security concern.

    What does the script on the other server do?
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Jul 2010

    Re: Ajax from a different domain

    You can do one thing, make an ajax call to the server side code(test.php) running on

    test.php will try to connect to the script located in and will return you the result. With this approach you have accessed the data from domain2 from domain1 using ajax call.

    Hope this helps.

    Hitesh Agarwal

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)