PDA

View Full Version : AJAX Works With IE8 and Firefox but not Opera.


ideffect
01-11-2010, 02:52 AM
Hey guys,

I'm a newbie with javascript/ajax and I am having a problem making a file upload progress bar work with Opera. It works perfectly in firefox and IE8. Any suggestions why it would not work in Opera would be greatly appreciated!

Here is the code...

Javascript

function upload_status(upload_id) {
document.getElementById('userfile').className = 'tab_hide';
document.getElementById('upload_status').className = 'tab_show';

if (window.XMLHttpRequest) {
http = new XMLHttpRequest();
}
else if (window.ActiveXObject) {
http = new ActiveXObject("Microsoft.XMLHTTP");
}
http.open("GET",'https://www.eckopublishing.com/xml_feeds.php?go=check_uplaod_status&unique_upload_id='+upload_id,true);
http.onreadystatechange = function (){
if (http.readyState == 4) {
var xmlObj = http.responseXML;
var percent = xmlObj.getElementsByTagName("percent").item(0).firstChild.data;
document.getElementById('upload_status_number').innerHTML = percent+' percent completed';
document.getElementById("upload_status_bar").style.width = percent+'%';
}
}
http.send(null);
setTimeout(function(){upload_status(upload_id); variable = null},500);
}


PHP
if ($go == 'check_uplaod_status') { //This checks the upload status of a file
$upload = apc_fetch ( 'upload_' . $unique_upload_id );
if ($upload) {
if ($upload ['done'])
$percent = 100;
else if ($upload ['total'] == 0)
$percent = 0;
else
$percent = $upload ['current'] / $upload ['total'] * 100;
}
$percent = ceil ( $percent );
//print_r ( apc_fetch ( "upload_$unique_upload_id" ) ); //This shows the vars
header ( 'Content-Type: text/xml' );
header ( 'Pragma: no-cache' );
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<percent>';
echo $percent;
echo '</percent>';
}

ideffect
01-27-2010, 09:23 PM
Does anyone know of any bugs in opera when dealing with ajax? I am still not able to figure out the problem.

Thanks