Topic
5 replies Latest Post - ‏2014-09-20T11:27:21Z by jitupkp
archiejr
archiejr
4 Posts
ACCEPTED ANSWER

Pinned topic activity icon

‏2011-12-24T11:08:42Z |
Hi,

This page demonstrates the issue: http://www.soundset.com/test.php

Here's how I'd like it to work:

  • display a link that runs a php script when clicked
  • while the script is running, display an animated gif to indicate activity
  • when the script is complete, the animation disappears

The test.php script works as described in Firefox 8, but not Chrome, Opera 11, Internet Explorer 9, or Safari 5. What could the trouble be?

Within the <head> of test.php is: <script type="text/javascript" src="test_activity.js"></script>. The content of test_activity.js is:
//Make the XMLHttpRequest Object
var http = GetXmlHttpObject();

function GetXmlHttpObject()
{
var req;

try
{
// Firefox, Opera, Safari
req = new XMLHttpRequest();
}

catch (e)
{
// Internet Explorer
try
{
//For IE 6
req = new ActiveXObject("Msxml2.XMLHTTP");
}

catch (e)
{
try
{
//For IE 5
req = new ActiveXObject("Microsoft.XMLHTTP");
}

catch (e)
{
alert('Your browser is not IE 5 or higher, or Firefox or Safari or Opera');
}
}
}

return req;
}

function send_activity_Request(method, url){
if(method == 'get' || method == 'GET'){
http.open(method,url,true);
http.onreadystatechange = handle_activity_Response;
http.send(null);
}

}

function handle_activity_Response(){
if(http.readyState == 4 && http.status == 200){
var response = http.responseText;
if(response){
document.getElementById("activity_response").innerHTML = response;
}
}
else
{
document.getElementById("activity_response").innerHTML='Activity... ';
}
}

Thanks!
Updated on 2011-12-24T11:19:55Z at 2011-12-24T11:19:55Z by archiejr
  • archiejr
    archiejr
    4 Posts
    ACCEPTED ANSWER

    Re: activity icon

    ‏2011-12-24T11:14:25Z  in response to archiejr
    The last line of the .js script did not display correctly in this forum. It is an image tag. Here it is without the opening and closing : img src="images/activity.gif".
    • archiejr
      archiejr
      4 Posts
      ACCEPTED ANSWER

      Re: activity icon

      ‏2011-12-24T11:17:12Z  in response to archiejr
      Here is the contents of call_test_activity_function.php:

      <?php

      $function_to_call = $_GET;

      switch ($function_to_call)
      {
      case 'test_activity':
      sleep(3);
      echo '<a href="test.php">Done</a>';
      break;
      }
      ?>
  • jitupkp
    jitupkp
    104 Posts
    ACCEPTED ANSWER

    Re: activity icon

    ‏2014-09-20T11:27:07Z  in response to archiejr

    see more

    http://techgurulab.com/course/ajax-quiz-online/