Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IE doesn't refresh the screen when a function is running

Status
Not open for further replies.

lmmoreira

Programmer
Jun 27, 2008
8
0
0
BR
Hi there, I have a cole like this:

function cCarregar(){
var div = document.createElement('div');
div.id = 'backCarrega';
div.className = 'back';
document.getElementById('lpDivs').appendChild(div);

var img = document.createElement('input');
img.type = 'image';
img.className = 'carregando';
img.src = 'carregando.png';
div.appendChild(img);
img.focus();
}

This is a function that shows a DIV with the text "Loading" on it.

I use it like this:
function carregar(procedure, inicio){
cCarregar()
var lista = $.ajax({url: '../PHP/sqlS.php', type:'POST', data:"sql=Select RESULT from "+procedure+"('"+codorganizacao+"','"+toJS(inicio)+"')", async:false, success:function(){}}).responseText;
carregaSelect(select1, lista, 0);
destroyCarregar()
}

When that code runs on Firefox it goes fine, but, on IE that the loading DIV doesn't appear.
When I wrote a alert("teste"); after img.focus(); on cCarregar(), it appeared.

I think IE can't refresh the screen to show the DIV.

How can I deal it ?

Thanks, sorry about my english, I'm from Brazil and I'm just learning.


 
I had a similar problem with one of my pages and I used JavaScript's setTimeout() function: This function takes two arguments: the function you want to run and the milliseconds you want to wait. Here's an example of how to delay calling cCarregar() for two seconds:

[tt]
function carregar(procedure, inicio){
setTimeout(cCarregar(),2000);
[/tt]


Hope this helps,
Larry
 
Actually it should be:

Code:
function carregar(procedure, inicio){
     setTimeout("cCarregar()",2000);

The statement in setTimeout should be a string. Without the quotes, the function "cCarregar()" is actually executed while the "setTimeout()" is executed, and the results of the cCarregar function would be placed in the statement side of setTimeout... not the function itself.

e.g. if cCarregar() returns "hello world", then these would be the same:

Code:
setTimeout(cCarregar(),2000);
setTimeout("hello world",2000);

So put quotes around it. ;-)

Cuvou.com | My personal homepage
Code:
perl -e '$|=$i=1;print" oo\n<|>\n_|_";x:sleep$|;print"\b",$i++%2?"/":"_";goto x;'
 
this way, the code:

function carregar(procedure, inicio){
setTimeout("cCarregar()",2000);
.
.
$.ajax ...
}

would wait 2 sec to be started correct?

But, there is a problem... I can't define 2 sec, because I don't know if It is 2 sec or 10 sec. It depends of the data to be loaded.

 
Kirsle said:
Actually it should be ...

Actually, it didn't need to be. Both setTimeout and setInterval can take either a string or a function reference as their first parameter.

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
Of course, if you omit the quotes, you have to omit the brackets as well, otherwise (as you mention) the function will execute immediately.

So this would also be fine:

Code:
setTimeout(cCarregar, 2000);

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
Hi

lmmoreira, what will happen if someone/something rewrites the function on the fly ? Will this be also executed ?
Code:
function carregar(procedure, inicio)
{
  cCarregar()
  var lista = $.ajax({url: '../PHP/sqlS.php', type:'POST', data:"sql=[red]drop function[/red] "+procedure, async:false, success:function(){}}).responseText;
  carregaSelect(select1, lista, 0);
  destroyCarregar()
}
Ignore the fact that I do not research on which SQL language are you using, so the syntax may be incorrect.

Feherke.
 
If someone do It, the table in procedure will be deleted....
but the "Loading" Screen would still not appear.
 
actualy, even with the setTimeout, It stills, not showing...

KILLLLLLLLLLLLLLLLLLL IE
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top