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

The Archive Base Latest Questions

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

I have the following function in javascript that calls the ajax which calls the

  • 0

I have the following function in javascript that calls the ajax which calls the php,
I would like to pass by parameter to the javascript function, the php page that i want to access and
the div id, all from html, follows the code that I have:

/————————————————–javascript———————————-/

function getXMLHttp() 
{
var xmlHttp

try
{
//Firefox, Opera 8.0+, Safari
xmlHttp = new XMLHttpRequest();
} 
catch(e)
{
//Internet Explorer
try
{
  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
  try
  {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
  catch(e)
  {
    alert("Your browser does not support AJAX!")
    return false;
  }
}
}
return xmlHttp;
}

function MakeRequest() 
{
var xmlHttp = getXMLHttp();

xmlHttp.onreadystatechange = function()
{
if(xmlHttp.readyState == 4)
{
  HandleResponse(xmlHttp.responseText);
}
}

xmlHttp.open("GET", "ajax.php", true);
xmlHttp.send(null);
}

function HandleResponse(response)
{
document.getElementById('ResponseDiv').innerHTML = response;
}

/————————————————–php———————————-/

<?php
echo "This is a php response to your request!!!!!!";
?> 

/————————————————–html———————————-/

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
    <script type='text/javascript' src='ajax.js'></script>
    <title>PHP AJAX Example</title>
  </head>
  <body>
    <input type='button' onclick='MakeRequest();' value='Use AJAX!!!!'/>
    <div id='ResponseDiv'>
      This is a div to hold the response.
    </div>
  </body>
</html>

thank you enormously …

  • 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-24T04:08:24+00:00Added an answer on May 24, 2026 at 4:08 am

    Don’t worry, I’m not going to tell you that you can’t re-invent the wheel if you want to. ^^

    function getXMLHttp() 
    {
        var xmlHttp
    
        try
        {
            //Firefox, Opera 8.0+, Safari
            xmlHttp = new XMLHttpRequest();
        } 
        catch(e)
        {
            //Internet Explorer
            try
            {
                xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch(e)
            {
                try
                {
                    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                }
                catch(e)
                {
                    alert("Your browser does not support AJAX!")
                    return false;
                }
            }
        }
        return xmlHttp;
    }
    
    function MakeRequest(page, obj) 
    {
        var xmlHttp = getXMLHttp();
    
        xmlHttp.onreadystatechange = function()
        {
            if(xmlHttp.readyState == 4)
            {
                HandleResponse(xmlHttp.responseText, obj);
            }
        }
    
        xmlHttp.open("GET", page, true);
        xmlHttp.send(null);
    }
    
    function HandleResponse(response, obj)
    {
        document.getElementById(obj).innerHTML = response;
    }
    

    Here is the HTML body component. Notice I used “quotes” and not ‘apostrophes’.

    <input type="button" onclick="MakeRequest('ajax.php', 'ResponseDiv');" value="Use AJAX!!!!"/>
    <div id='ResponseDiv'>
      This is a div to hold the response.
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following function which pulls in a Javascript block via AJAX from
I have the following JavaScript code: Link In which the function makewindows does not
I have the following javascript code, which loads without error, however the update function
I have the following function that is pulling data from a database. The ajax
I have the following Javascript function that should return an array of groups that
I have a simple PHP page (for testing) that simply calls header(Location: http://www.example.com );exit;
I have a strange need. I would like to do the following in javascript:
I have a calc function in java script that takes three integer parameters, following
I have Designed the Javascript function My.js it contains following code My.js function display(){
I have the following code: <script type=text/javascript> function SubmitForm() { form1.submit(); } function ShowResponse()

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.