By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,991 Members | 1,888 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,991 IT Pros & Developers. It's quick & easy.

Script doesn't work without alerts :(

P: n/a
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

Jan 5 '06 #1
Share this Question
Share on Google+
10 Replies


P: n/a
> 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

Jan 5 '06 #2

P: n/a
>>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.


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

Jan 5 '06 #3

P: n/a
VK

Jarod wrote:
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.


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).

Jan 5 '06 #4

P: n/a
>> 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*


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

Jan 5 '06 #5

P: n/a
>>>>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.


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()?


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

Jan 5 '06 #6

P: n/a
VK

Jarod wrote:
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.

Jan 5 '06 #7

P: n/a
> 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

Jan 5 '06 #8

P: n/a
"Jarod" <bl*****@NOSPAM.gazeta.pl> writes:
xmlDoc.async = false;
xmlDoc.load(service);
alert("now it works");
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
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jan 6 '06 #9

P: n/a
>>> xmlDoc.async = false;
xmlDoc.load(service);
alert("now it works");

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).


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

Jan 6 '06 #10

P: n/a
VK

Jarod wrote:
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.

Jan 7 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.