Jump to content

[SOLVED] Trying to Load a File


lilman

Recommended Posts

I am trying to request a file that will load in a div tag.  Assume the div tag is there, can anyone point out what could be causing the problem.  It works fine in Firefox, but not I.E.. Here is the Ajax code:

 

<?php

echo $_SERVER['PHP_SELF'];

?>

<script type="text/javascript">

var xmlhttp=false;

if (!xmlhttp && typeof XMLHttpRequest!='undefined')

{

try

{

xmlhttp = new XMLHttpRequest();

}

catch (e)

{

xmlhttp=false;

}

}

 

 

if (!xmlhttp)

{

try

{

xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");

}

catch (e)

{

try

{

xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

}

catch (E)

{

xmlhttp = false;

}

}

}

 

 

if (!xmlhttp && window.createRequest) {

try {

xmlhttp = window.createRequest();

} catch (e) {

xmlhttp=false;

}

}

 

var please_wait = "Please wait...";

 

function statusEnableDisable(url, targetId, form)

{

var status;

 

if(form == "photoalbum"){

var object = document.getElementById('photoalbum').selectedIndex;

 

if(object == "1"){

status = "Enabled";

}

else if(object == "2"){

status = "Disabled";

}

}

else if(form == "file"){

var object = document.getElementById('filestorage').selectedIndex;

 

if(object == "1"){

status = "Enabled";

}

else if(object == "2"){

status = "Disabled";

}

}

 

url = url + "status=" + status;

url = url + "&form=" + form;

alert(url);

 

 

 

if(!xmlhttp)return false;

var e=document.getElementById(targetId);

if(!e)return false;

if(please_wait)e.innerHTML = please_wait;

 

xmlhttp.open("GET", url, true);

xmlhttp.onreadystatechange = function() { response(url, e); }

 

    try

{

      xmlhttp.send(null);

    }

catch(l)

{

while(e.firstChild)e.removeChild(e.firstChild);//e.innerHTML="" the standard way

e.appendChild(document.createTextNode("request failed"));

}

 

}

 

function response(url, e)

{

  if(xmlhttp.readyState != 4)return;

var tmp= (xmlhttp.status == 200 || xmlhttp.status == 0) ? xmlhttp.responseText : "Ooops!! A broken link! Please contact the webmaster of this website ASAP and give him the following error code: " + xmlhttp.status+" "+xmlhttp.statusText;

   

if(xmlhttp.readyState == 4)

{

alert('complete');

 

}

 

var d=document.createElement("div");

    d.innerHTML=tmp;

    setTimeout(function()

{

  while(e.firstChild)e.removeChild(e.firstChild);//e.innerHTML="" the standard way

  e.appendChild(d);

    },10)

 

}

</script>

Link to comment
https://forums.phpfreaks.com/topic/63291-solved-trying-to-load-a-file/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.