Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. PHP, Ajax function in IE

PHP, Ajax function in IE

Scheduled Pinned Locked Moved Web Development
databasephpmysqltoolsquestion
2 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bryant May
    wrote on last edited by
    #1

    Ive written a function which works in Firefox but not in IE, in fact there are several things about this page that dont work in IE but this is the main one!! I have a list view within a CMS that is displaying a list of pages within a web site. Part of the list is a status indicator (A graphic) which is either green, orange or red dependent on the current status of the page. Ive written an onclick Ajax function that alters the image and updates the DB stored status of the page. This is accomplished everytime the image is clicked - The icon is altered based on its current state, the function is called which creates an Ajax object, passes the current state and the id of the page to a PHP script which updates the mysql database. NOTHING IS RETURNED FROM THE PHP SCRIPT. The code for this is as follows: //PHP function call

      showStatus($myRow\['id'\], $myRow\['status'\], $userID);
    

    PHP function definition

    function showStatus($id, $status, $editor)
    {
    if ($status == "1")
    print "";
    if ($status == "5")
    print "";
    if ($status == "9")
    print "";
    }

    function getStatus(id, editor)
    {
    createObject();

    if (XMLHttpRequestObject)
    {
    	var url = "/cms/functions/ajax/getStatus.php?id=" +id;
    	
    	XMLHttpRequestObject.open("GET", url, true);
    	
    	XMLHttpRequestObject.onreadystatechange = function()
    	{
    		if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200)
    		{
    			var result = XMLHttpRequestObject.responseText;	
    			changeStatus(id, result, editor);			
    		}
    	}
    	XMLHttpRequestObject.send(null);
    }	
    

    }

    //AJax function definition
    function changeStatus(id, currentStatus, editor)
    {
    createObject();

    if (XMLHttpRequestObject)
    {
    	var icon = document.getElementById("statusIcon"+id);
    	var url = "/cms/functions/ajax/statusUpdater.php?id=" +id+"&editor=" +editor+ "&curState=" +currentStatus;
    	
    	XMLHttpRequestObject.open("GET", url, true);
    	
    	XMLHttpRequestObject.onreadystatechange = function()
    	{
    		if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200)
    		{
    			
    			var result = XMLHttpRequestObject.responseText;
    		
    			if (currentStatus == 1)
    			{
    				icon.src = "images/system/paused.gif";
    			}
    			if (currentStatus == 5)
    			{
    				icon.src = "images/system/stopped.gif";
    			}
    			if (currentStatus == 9)
    			{
    				icon.src = "images/system/active.gif";
    			}
    		}
    	}
    	XMLHttpRequestObject.send(null);
    }	
    

    }

    AND FINALLY // The php mysql update

    F 1 Reply Last reply
    0
    • B Bryant May

      Ive written a function which works in Firefox but not in IE, in fact there are several things about this page that dont work in IE but this is the main one!! I have a list view within a CMS that is displaying a list of pages within a web site. Part of the list is a status indicator (A graphic) which is either green, orange or red dependent on the current status of the page. Ive written an onclick Ajax function that alters the image and updates the DB stored status of the page. This is accomplished everytime the image is clicked - The icon is altered based on its current state, the function is called which creates an Ajax object, passes the current state and the id of the page to a PHP script which updates the mysql database. NOTHING IS RETURNED FROM THE PHP SCRIPT. The code for this is as follows: //PHP function call

        showStatus($myRow\['id'\], $myRow\['status'\], $userID);
      

      PHP function definition

      function showStatus($id, $status, $editor)
      {
      if ($status == "1")
      print "";
      if ($status == "5")
      print "";
      if ($status == "9")
      print "";
      }

      function getStatus(id, editor)
      {
      createObject();

      if (XMLHttpRequestObject)
      {
      	var url = "/cms/functions/ajax/getStatus.php?id=" +id;
      	
      	XMLHttpRequestObject.open("GET", url, true);
      	
      	XMLHttpRequestObject.onreadystatechange = function()
      	{
      		if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200)
      		{
      			var result = XMLHttpRequestObject.responseText;	
      			changeStatus(id, result, editor);			
      		}
      	}
      	XMLHttpRequestObject.send(null);
      }	
      

      }

      //AJax function definition
      function changeStatus(id, currentStatus, editor)
      {
      createObject();

      if (XMLHttpRequestObject)
      {
      	var icon = document.getElementById("statusIcon"+id);
      	var url = "/cms/functions/ajax/statusUpdater.php?id=" +id+"&editor=" +editor+ "&curState=" +currentStatus;
      	
      	XMLHttpRequestObject.open("GET", url, true);
      	
      	XMLHttpRequestObject.onreadystatechange = function()
      	{
      		if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200)
      		{
      			
      			var result = XMLHttpRequestObject.responseText;
      		
      			if (currentStatus == 1)
      			{
      				icon.src = "images/system/paused.gif";
      			}
      			if (currentStatus == 5)
      			{
      				icon.src = "images/system/stopped.gif";
      			}
      			if (currentStatus == 9)
      			{
      				icon.src = "images/system/active.gif";
      			}
      		}
      	}
      	XMLHttpRequestObject.send(null);
      }	
      

      }

      AND FINALLY // The php mysql update

      F Offline
      F Offline
      fly904
      wrote on last edited by
      #2

      I suggest using JQuery[^] as it's functionality is compatible in all(most) browsers as far as I know. Then you may want to use the Ajax Post Method[^] as I find it easier.

      hmmm pie

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups