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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:51:16+00:00 2026-05-28T02:51:16+00:00

I have this simple ajax code, for some reason it wont load content onto

  • 0

I have this simple ajax code, for some reason it wont load content onto textarea. I need it to load the content so that it can be edited in the textarea.

Here’s the code, I’m not sure what I’m doing wrong. But it displays in a div like so

<div id="content"></div>

Here’s the full code

<html>
<head>
<title>Editing Page Content</title>

<script type="text/javascript">
function showCustomer(str)
{
var xmlhttp;    
if (str=="")
  {
  document.getElementById("content").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("content").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","load.php?file="+str,true);
xmlhttp.send();
}
</script>

</head>
<body>
    <p>Page Select to edit</p>      

        <?php  

             $result = mysql_query("SELECT pagename FROM site_content");            
                echo "<select name=\"pagename\" onchange=\"showCustomer(this.value)\" style=\"width:300px;\">";             
                echo "<option selected  value=''>Please select a page to edit...</option>";             
                 while($row = mysql_fetch_assoc($result)){ 
                 echo "<option selected value='" . $row['pagename'] ."'>" . $row['pagename'] . "</option>\n";           
               }            
             echo "</select>";          

             ?>     

            <div id="content">
                 **it works here**
             </div>

            <textarea cols="50" id="area1" style="position: absolute; width: 700px; height: 300px;">
                     **It won't work here**
            </textarea>  

            <input type="button" value="Submit content">  

            </div>     
        </body>             
</html>

Any help would be appreciated.

  • 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-28T02:51:17+00:00Added an answer on May 28, 2026 at 2:51 am

    From your code this looks to do exactly what you want:

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

    Since your div has the id of “content” the response is being put there. Try something like:

    document.getElementById("area1").value = xmlhttp.responseText;
    

    I must also advise you to take a look at the PHP documentation on choosing a MySQL API as mysql_* is considered outdated and is in a long-term deprecation.

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

Sidebar

Related Questions

I have some simple ajax code. All I want to do is load a
I have this simple code that speaks for itself. <script language='javascript"> function check() {}
Let's say I have this code: <div id=content> </div> and I use a simple
I have an ajax form in asp.net mvc which is as simple as this:
I have this simple regex, [\d]{1,5} that matches any integer between 0 and 99999.
I have this simple example I can't seems to get working : MERGE INTO
I have this simple grammar for a C# like syntax. I can't figure out
I have some code that retrieves a scripted svg image from a server via
I've got a simple $.ajax request that I am trying to fetch some HTML
I have a very simple javascript class that does an ajax call to a

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.