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

  • SEARCH
  • Home
  • 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 6028911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:48:33+00:00 2026-05-23T04:48:33+00:00

I have my JavaScript files on my main domain and I want to do

  • 0

I have my JavaScript files on my main domain and I want to do some calls from the subdomain.

I have added:

url: "http://domain.com/ajax.php"

So the full code is:

    $.ajax({
        type: "POST",
        url: "http://domain.com/ajax.php",
        data: {
            var1: var1,
            var2: var2
        },
        success: function(data){

        }
    });

But on Firebug it shows the request as red and it fails to respond. Also the POST parameters are there as they should.

Should I create a new JS file on the subdomain and add the necessary codes and do from there the AJAX calls?

EDIT: using JSONP code

I am using this on localhost/ajax.php, which I call from sub.localhost

    $.ajax({
        dataType: 'jsonp',
        data: 'id=10',
        jsonp: 'jsonp_callback',
        url: 'http://localhost/ajax.php',
        success: function (data) {
            console.log(data);
        },
    });

and the ajax.php contains:

<?php
echo $_GET["id"];
?>
  • 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-23T04:48:33+00:00Added an answer on May 23, 2026 at 4:48 am

    You can use Access-Control-Allow-Origin header to enable cross-domain requests.

    Read this: Cross-Origin Resource Sharing (CORS)

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

Sidebar

Related Questions

I have this js file serving from some domain say foobar.com at http://foobar.com/static/js/main.js: $(document).ready(function()
I have a javascript file main.js and five html files 1.html,2.html,3.html,4.html,5.html I want to
I have some external Javascript files in my GWT app that I only want
I have seen a main() function in some JavaScript files I have come across.
I have some pages that reference javascript files. The application exists locally in a
I have a typical setup for cross domain. site1.company.com site2.company.com Main application is running
I have a Rhino project where I've written some .js files, and from Eclipse
I'm busy on a project and I have some extra javascript files that need
We have a web site in the domain, let's name: http://website.com . It is
I have created two JavaScript files. One file is "validators.js" and the other 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.