Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6796843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:32:11+00:00 2026-05-26T18:32:11+00:00

In host1 with domain http://domain1 I am using ajax with structure: index.php (that is

  • 0

In host1 with domain http://domain1 I am using ajax with structure:

  1. index.php (that is include ajax)
  2. config.php (connect database)
  3. get_city.php

code here:

index.php
$(document).ready(function(){
   $('.nation').change(function(){
        var id = $(this).val();
        var dataString = 'id='+id;
        $.ajax({
           type: 'POST',
           url: '**http://domain1/get_data.php**',
           data: dataString,
           cache: false,
           success: function(html) {
                $('.city').html(html);
           } 
        });
   });
});

in get_city.php:

<?php
include 'config.php';
$id = $_POST['id'];
if($id) {
    $query = mysql_query("Select * From  jos_city Where nation_id = id");
    while($row = mysql_fetch_array($query)) {
        $id = $row['id'];
        $name = $row['city_name'];
        echo '<option value="'.$id.'">'.$name.'</option>';
    }
}

When I use the other host with domain http://domain2, then ajax can’t load

 $(document).ready(function(){
       $('.nation').change(function(){
            var id = $(this).val();
            var dataString = 'id='+id;
            $.ajax({
               type: 'POST',
               url: '**http://domain1/get_data.php**',
               data: dataString,
               cache: false,
               success: function(html) {
                    $('.city').html(html);
               } 
            });
       });
    });

I think, the error occurs when calling the url: ‘http://domain1/get_data.php‘ from domain1 to domain2. Has anybody got an idea, why this might happen?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:32:12+00:00Added an answer on May 26, 2026 at 6:32 pm

    AJAX calls must conform to same origin policy, you cannot make plain AJAX calls to another domain.

    There are, however, workarounds:

    To enable developers to, in a controlled manner, circumvent the Same Origin Policy, a number of ‘hacks’ such as using the Fragment Identifier, or the window.name property have been used to pass data between documents residing in different domains. With the HTML5 standard a method was formalized for this: the postMessage interface, which is only available on recent browsers. JSONP and Cross-Origin Resource Sharing can also be used to enable AJAX-like calls to other domains.[2]

    For supporting older browsers, the JavaScript library easyXDM can be used to provide a unified API for the postMessage interface as well as a number of hacks used to allow Cross Domain Messaging (XDM).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following config in my lighttpd.conf: $HTTP[host] == trac.domain.tld { server.document-root =
Help! I have a PHP (PHP 5.2.5) script on HOST1 trying to connect to
Im using this code http://platinumdogs.wordpress.com/2008/10/30/net-c-impersonation-with-network-credentials/#comment-770 to connect from a machine in the domain to
I'm using a host that will only allow PHP files to be located in
I am using Google Apps for domain to host the email from my domain
i have a domain full-ops.com that i transferred to another host, but it takes
Let's imagine that I have list of files at host1 find /path/to -name *.jpg
I have three domains (domain1.es, domain2.com, domain3.com). I need that: domain1.es OR www.domain1.es, show
I'm trying to use a Web Service using PHP and SOAP. The Web Service
I have domain1.tld and domain2.tld. Domain1.tld is the primary domain name and domain2.tld is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.