Script doesn't work without alerts :(

J

Jarod

Hey
var service = this.WebServiceURL +"/SessionFun?sessionID="+ this.SessionID ;

var xmlDoc=document.implementation.createDocument("", "", null);


try

{

xmlDoc.async = false;

xmlDoc.load(service);

alert("now it works");

}



When you delete last alert the xmlDoc in older browser will be empty :( I
tried to put a pause there I wrote a code that just stops browser for 1, 2,
10 seconds... but the xmlDoc is still empty. And if I hit an alert after 0,1
s it works. How to make it work without alert ?

Jarod
 
J

Jarod

Hey
var service = this.WebServiceURL +"/SessionFun?sessionID="+ this.SessionID
;

var xmlDoc=document.implementation.createDocument("", "", null);


try

{

xmlDoc.async = false;

xmlDoc.load(service);

alert("now it works");

}



When you delete last alert the xmlDoc in older browser will be empty :( I
tried to put a pause there I wrote a code that just stops browser for 1,
2, 10 seconds... but the xmlDoc is still empty. And if I hit an alert
after 0,1 s it works. How to make it work without alert ?
I forgot to mention that it doesn't work in NN 7.0.In higher versions like
NN 8.0 and FF 1,5 works great.
Jarod
 
L

Lee

Jarod said:
When you delete last alert the xmlDoc in older browser will be empty :( I
tried to put a pause there I wrote a code that just stops browser for 1, 2,
10 seconds... but the xmlDoc is still empty.

What sort of code did you write to stop the browser?
Unless you used setTimeout(), you probably stopped your browser from doing
anything at all, including loading the document.
 
J

Jarod

When you delete last alert the xmlDoc in older browser will be empty :( I
What sort of code did you write to stop the browser?
Unless you used setTimeout(), you probably stopped your browser from doing
anything at all, including loading the document.

it doesn't matter I tried to use some pause function with while I tried
setTimeout doesn't matter. And it can take even 10s and doesn't help. But
one alert for 0,05s is great. Maybe there is a way to display and close
alert from code ?
Jarod
 
L

Lee

Jarod said:
it doesn't matter I tried to use some pause function with while I tried
setTimeout doesn't matter. And it can take even 10s and doesn't help. But
one alert for 0,05s is great. Maybe there is a way to display and close
alert from code ?

No. How did you try to use setTimeout()?
 
V

VK

Jarod said:
it doesn't matter I tried to use some pause function with while I tried
setTimeout doesn't matter. And it can take even 10s and doesn't help. But
one alert for 0,05s is great. Maybe there is a way to display and close
alert from code ?

First of all,
async = true
*always and forever*

Synchronized requests simply do not work in JavaScript without real
thread management mechanics. More correctly - they do "work" but it's
far away from what you would call "work" for a synchronized process.
So simply forget that this flag exists (default value is true, exactly
what you need). For request status there is readyState property, so you
have to emulate *normal* synchronization manually over
onreadystatechange. Thank you very much to script engine makers (on
both sides), but what is - it is.

Secondly: it is forbidden by the rules of this universe :) what
synchronized thread "works" upon alert(), and upon alert() only. That
must be a combined bug where several errors are twisted together. More
code would help.

Also it may be connected with alert() call priority so system let it go
through or even changes async from true to false. That's a *pure
speculation* as async=true behavior is studied rather badly (as no one
uses it).
 
J

Jarod

it doesn't matter I tried to use some pause function with while I tried
First of all,
async = true
*always and forever*

I tried it before writting to group nothing changed. With alert it works
without alert it doesn't.
Also it may be connected with alert() call priority so system let it go
through or even changes async from true to false. That's a *pure
speculation* as async=true behavior is studied rather badly (as no one
uses it).

Any ideas how to make it work ?
Jarod
 
J

Jarod

When you delete last alert the xmlDoc in older browser will be empty
No. How did you try to use setTimeout()?

For real it doesn't matter because it doesn't work in anyway.
But let's say:

xmlDoc.onload = window.setTimeout(...);
without using xmlDoc.onload... just after xmlDoc.load()
window.setTimeout(...)
Of course non of them helped ( but it worked code was paused ).
Jarod
 
V

VK

Jarod said:
Any ideas how to make it work ?

If by "it" you mean the originally posted piece:

var service = this.WebServiceURL +"/SessionFun?sessionID="+
this.SessionID ;
var xmlDoc=document.implementation.createDocument("", "", null);
try
{
xmlDoc.async = false;
xmlDoc.load(service);
alert("now it works");
}

then no one knows I guess because there is nothing explicetly terrible
in it, but "this.WebServiceURL" suggests that this is a part of a
constructor we have no idea about. So please either post the code or
provide a link.
 
J

Jarod

If by "it" you mean the originally posted piece:
var service = this.WebServiceURL +"/SessionFun?sessionID="+
this.SessionID ;
var xmlDoc=document.implementation.createDocument("", "", null);
try
{
xmlDoc.async = false;
xmlDoc.load(service);
alert("now it works");
}

then no one knows I guess because there is nothing explicetly terrible
in it, but "this.WebServiceURL" suggests that this is a part of a
constructor we have no idea about. So please either post the code or
provide a link.

this.WebServiceURL = http://localhost/myWebservice.asmx;
and this code as a whole not this peace works in all new browsers but it
doesn't in NN 7.0.
If I add "alert("");" like in above it works in NN 7.0. Question is how to
make it work without alert.
Jarod
 
L

Lasse Reichstein Nielsen

If I add "alert("");" like in above it works in NN 7.0. Question is
how to make it work without alert.

If adding alert changes anything, it suggests a timing problem.
The "xmlDoc.async = false" assignment suggests that something
could happen asynchroneously. If it did, then maybe a delay is
needed, so my suggestion would be that the assignment fails to
make the request synchroneous in NN7. You could live with that
and change it to always be asynchroneous, or you could look
for a workaround for NN7 (as well as a way to safely detect
the need for that workaround).

/L
 
J

Jarod

xmlDoc.async = false;
If adding alert changes anything, it suggests a timing problem.
The "xmlDoc.async = false" assignment suggests that something
could happen asynchroneously. If it did, then maybe a delay is
needed, so my suggestion would be that the assignment fails to
make the request synchroneous in NN7. You could live with that
and change it to always be asynchroneous, or you could look
for a workaround for NN7 (as well as a way to safely detect
the need for that workaround).

Async set to true doesn't change anything ;( I tried it. But I don't know
why this alert makes it work ? [It's probably not about time... but about
some interuption ...]
Jarod
 
V

VK

Jarod said:
Async set to true doesn't change anything ;( I tried it. But I don't know
why this alert makes it work ? [It's probably not about time... but about
some interuption ...]

Netscape 7.x is mainly forgotten beast. But here a very similar code
claimed to work for Netscape 7.x:
<http://www.stylusstudio.com/xsllist/200411/post50020.html>

and here is a working sample of this code:
<http://users.telenet.be/cking/webstuff/dynamic-xslt/dynamic.html>

It works for Firefox 1.5, check it for your Netscape.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top