Bug 85546 - An image is not loaded and/or displayed while waiting for synchronous XMLHttpRequest
Summary: An image is not loaded and/or displayed while waiting for synchronous XMLHttp...
Status: RESOLVED WONTFIX
Alias: None
Product: WebKit
Classification: Unclassified
Component: Page Loading (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Major
Assignee: Nobody
URL:
Keywords: InRadar
: 84032 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-05-03 14:56 PDT by Teo
Modified: 2012-05-10 15:54 PDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Teo 2012-05-03 14:56:37 PDT
Javascript doesn't do nothing before the end of the entire script!

If I try to execute the function prova() from the following simple code, it prints only the variable "risultato" without showing people the image attendi.gif!
In other browser, like Mozilla, it shows the image during the XmlHttpObject ... waiting, and when it receives the result it substitutes the image with the result!

function GetXmlHttpObject()
{
	var objXMLHttp=null;
	if (window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	return objXMLHttp;
}

function prova()
{
	var newdiv = document.createElement("div");
		newdiv.setAttribute('id', 'extra');
		var vecchio = document.getElementById('extra');
		vecchio.parentNode.replaceChild(newdiv,vecchio);
	
				var newimg = document.createElement("img");
				var src='images/attendi.gif?'+variab;newimg.setAttribute('src', src);
				newimg.setAttribute('alt', 'Attendi ...');
				document.getElementById('extra').appendChild(newimg);
	}
	var xmlHttp = GetXmlHttpObject();
	var i=0;

	var url="http://www.mysite.com/script.php";

		if (!xmlHttp)
		{
			alert ("Browser does not support HTTP Request");
			return;
		}
		xmlHttp.open("GET", url, false);
		xmlHttp.send(null);
		var risposta=xmlHttp.responseText;
		risposta = risposta.replace("&lt;","<");
		risposta = risposta.replace("&gt;",">");
		if (risposta=='bye')
		{
			risultato="YES";
		}
		else
		{
			risultato="NO";
		}

		var newdiv = document.createElement("div");
		newdiv.setAttribute('id', 'extra');
		var vecchio = document.getElementById('extra');
		vecchio.parentNode.replaceChild(newdiv,vecchio);
		var newgrassetto = document.createElement("b");
		newgrassetto.setAttribute("style","color:red;");
		newgrassetto.innerHTML=risultato;
		document.getElementById("extra").appendChild(newgrassetto);

}
Comment 1 Alexey Proskuryakov 2012-05-03 16:28:56 PDT
Please don't use synchronous XMLHttpRequest.

The Mozilla behavior where it only partially freezes the browser causes a lot of other bugs, so we do not intend to do the same.
Comment 2 Alexey Proskuryakov 2012-05-03 16:33:13 PDT
For Apple employees: this is <rdar://problem/6653209>.
Comment 3 Teo 2012-05-10 15:54:51 PDT
*** Bug 84032 has been marked as a duplicate of this bug. ***