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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:38:15+00:00 2026-05-22T01:38:15+00:00

I am trying to execute a script in a div tag by AJAX. But

  • 0

I am trying to execute a script in a div tag by AJAX. But in the div tag the script does not run.
Here is my Code:

<div id="div0" align="right">
  <script type="text/javascript">
  <!--
    alert("Hi");
  -->
  </script>
</div>  

It does not work for me. Please anybody tell me, what is the problem?

Edit:

My complete code is that:

<html>  
   <head>  
   <script type="text/javascript">
      var xmlhttp;
      function loadXMLDoc(url)
      {
        xmlhttp=null;
        if (window.XMLHttpRequest)
        {// code for Firefox, Opera, IE7, etc.
          xmlhttp=new XMLHttpRequest();
        }
        else if (window.ActiveXObject)
        {// code for IE6, IE5
          xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        if (xmlhttp!=null)
        {
          xmlhttp.onreadystatechange=state_Change;
          xmlhttp.open("GET",url,true);
          xmlhttp.send(null);
        }
        else
        {
          alert("Your browser does not support XMLHTTP.");
        }
      }

     function state_Change()
     {
      if (xmlhttp.readyState==4)
      {// 4 = "loaded"
        if (xmlhttp.status==200)
        {// 200 = "OK"
         document.getElementById('T1').innerHTML=xmlhttp.responseText;
        }
        else
        {
          alert("Problem retrieving data:" + xmlhttp.statusText);
        }
     }
   }
   </script>
   </head>

   <body onload="loadXMLDoc('test_xmlhttp.php')">
     <div id="T1"></div><br />
   </body>

  </html>  

My test_xmlhttp.php is as follows:

  <script type="text/javascript">
  <!--
    alert("Hi");
  -->
  </script>

I want an alert box shows Hi when the AJAX is completed. But Nothing happens. Please Please Please give me a solution.

  • 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-22T01:38:16+00:00Added an answer on May 22, 2026 at 1:38 am

    try using eval() function in your state_Change function as below:

    document.getElementById('T1').innerHTML=eval('('+xmlhttp.responseText+')');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to execute this but cant see any result: <script> function init()
I'm trying to execute a script from within my java code which looks like:
I have a snippet of code, simply trying to execute a script on a
i am trying to execute awk script below on solaris but it's giving error
I'm trying to execute a script on an iframe inside IE but i get
So I am trying to execute some script from my php code. That lives
I am trying to execute a basic script on my server to automatically run
I'm trying to execute a .bat script in a C# windows service but it
Im trying to submit a form with Ajax here's my simplified code My index:
Im trying to build a form which uses AJAX but its failing to execute

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.