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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:39:52+00:00 2026-06-09T09:39:52+00:00

I am calling a very simple PHP page with some equally simple AJAX, but

  • 0

I am calling a very simple PHP page with some equally simple AJAX, but the call always returns nothing, even though the PHP is fine. That is, you can go to the URL of the PHP page and see that it echoes “Hello World” but when it is called with JS, it returns nothing.

Below is the HTML Page with the Javascript:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Title of the document</title>
</head>

<body>
The content of the document......<br />

Enter your email: <input id="email" type="text" />
<input type="button" onclick="setXMLHttpRequest()" value="Go!" />

<script type='text/javascript'/>

        var http;

        function setXMLHttpRequest()
        {
            if(window.XMLHttpRequest)
                http = new XMLHttpRequest();
            else if(window.ActiveXObject)
                http = new ActiveXObject("Microsoft.XMLHTTP");

                url = "http://www.convolutedconstruct.com /Ajax/checkemail.php?email=" + 
                                   document.getElementById('email').value;
                http.onreadystatechange = display;
                http.open("GET", url, true);
                http.send(null);

        }

        function display()
        {
            if (http.readyState == 4)
            {   
                infostr = http.responseText;
                alert("From the PHP: " + infostr);
            }
        }
</script></body></html>

Here is the content of the PHP page
Click here for the live PHP page

<?php
$email = $_GET['email'];
echo "Hello World!";
?>

Why does this return nothing to the JS, even though the PHP page echoes the text correctly?

  • 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-06-09T09:39:54+00:00Added an answer on June 9, 2026 at 9:39 am

    As has been suggested above, AJAX request will only work usually when both the caller and called are on same domain, You have to ensure that your html code, which contains the javascript, resides on same domain http://www.convolutedconstruct.com.

    If that is not the case you can use CORS to allow your ajax to receive input from your php page by sending this header in your php output

    <?php
    header("Access-Control-Allow-Origin: *");
    //rest of your code
    ?>
    

    See: http://enable-cors.org/

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

Sidebar

Related Questions

I have a PHP form that needs some very simple validation on submit. I'd
I feel like this must be very simple, but for some reason I am
when calling PQconnectdb in the main program all run very well, but if i
Calling the ajax called URL works well without ajax eg. http://localhost/ci/controller/method/param_value . But using
Using a very simple set of objects for this example in PHP. Lets say:
I shall show you very simple example, very is calling factorial counting with recursion,
I have the following, very simple CFC that I'm calling with jQuery. It works
I got a very simple user control (visifire charts + datepickers and some radiobuttons
Very simple class(source below) written in Python. After constructing obj1 = myClass(12) and calling
Im playing about with some very simple windows forms. I have an event handler

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.