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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.