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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:34:21+00:00 2026-05-28T00:34:21+00:00

sorry but Im unable to understand these example. I started learning ajax right from

  • 0

sorry but Im unable to understand these example. I started learning ajax right from today.

I have understood the below script so far

if (window.XMLHttpRequest)
  {
   xmlhttp=new XMLHttpRequest();
  }
else
 {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
 }

but in the below script

xmlhttp.onreadystatechange=function()
 {
   if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
     document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
 }

why do we use document.getElementById("txtHint").innerHTML=xmlhttp.responseText. I dont understand why we are doing these.Could anyone kindly explain me these, Im not sure if the above script is optional or not, please let me know it.

and also the post method in Ajax

xmlhttp.open("POST","test.php",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("fname="+str);

what is the use of xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); Im unable to understand the parameters of it and why it is being used , what does it really do in the script. what do we mean by content-type and application/x-www-form-urlencoded and its still working, even i dont give any user options

please help me with these both Then i believe I have completed the Ajax tutorials.Thanks

  • 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-28T00:34:22+00:00Added an answer on May 28, 2026 at 12:34 am
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    

    This basically just set textHint with whatever result the AJAX has (xmlhttp.responseText). And textHint could be simple html code with ID textHint:

    <div id="textHint"></div>
    

    That code is absolutely optional. You can do whatever process you want with the AJAX result, EG:

    • alerting it: alert(xmlhttp.responseText);
    • do further process, maybe processing the XML (if it’s XML document) or do JSON processing.
    • Just anything you want.

    For the next question:

    xmlhttp.open("POST","test.php",true);
    xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xmlhttp.send("fname="+str);
    

    is equal to sending HTML form:

    <form method="POST"><input type="hidden" name="fname" value="{str}"/></form>
    

    It try to send form data fname to server script test.php using POST method and transporting the data using MIME-TYPE application/x-www-form-urlencoded. You can read the full specification in W3 site.

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

Sidebar

Related Questions

sorry but I do not have the actual code with me, but I will
I am sure this will have been answered but I proved unable to find
I have checked the whole site and googled on the net but was unable
Sorry being a bit daft. But I come to understand (my lack of knowledge)
Sorry if this has been asked before, but I was unable to find it.
Sorry friends if this question is very easy but i am confuse i unable
First of I'm very sorry but this questions is not so so specific. All
Sorry about the vague subject but I couldn't think what to put. Here's my
Sorry for the simple question but I feel like there's a smarter way to
sorry for the lame question but with HTTP handler it is easy to do

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.