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 430007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:49:54+00:00 2026-05-12T19:49:54+00:00

This is the first time ever I’m using AJAX, and I want to do

  • 0

This is the first time ever I’m using AJAX, and I want to do the following on an otherwise static page http://www.xyz.org/some_site.html:

  • Send a GET request to another url "www.xyz.org/testscript"
  • if response has either status code != 200 or content != 'ok': do nothing
  • else: include sth on the website (i.e. set style="display:block" on an element that previously had "display:none")

I’ve implemented that successfully using basic AJAX. But:

There is an Apache redirect installed pointing from www.xyz.org/testscript to subdomain.xyz.org/testscript, the URL where the actual testscript lives (as AJAX doesn’t support cross-domain calls even to subdomains afaik).

When I call http://www.xyz.org/testscript I get a 302 status code, and the content says “The document has moved here: subdomain.xyz.org/testscript”.

How can I grab the ‘final’ return value?

I guess/hope any AJAX expert can give me a one-liner to solve that …

  • 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-12T19:49:54+00:00Added an answer on May 12, 2026 at 7:49 pm

    AJAX (or XMLHttpRequest to be acurate) won’t be tricked by a redirect. To be able to get content from another domain you need to use a proxy on the server. The following is a simple PHP proxy:

    if(strpos($_GET['q'], "http://") === 0){
      echo file_get_contents($_GET['q']);
    }
    

    use it like this:

    xhr.open(GET, "www.xyz.org/proxy.php?q=subdomain.xyz.org/testscript", true);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is my first time using Eclipse, and my first time programming in a
I'm using two threads in an iPhone app for the first time and I've
I've spent about 10 hours trying to find this bug that was causing my
I have the weirdest bug ever... I'm experimenting with display: table, and my proof
I've written a class whose .__hash__() implementation takes a long time to execute. I've
I feel like a bit of a newbie posting this, but anyway: I have
Before you tell me that there is already a similar question, yes, i know,
I have a linked list of structures. Lets say I insert x million nodes
Today at work I had a discussion with my co-workers and my boss about
I've been asked to set up a site to sell a single product online,

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.