Script doesn't work without alerts :(

Discussion in 'Javascript' started by Jarod, Jan 5, 2006.

  1. Jarod

    Jarod Guest

    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
    Jarod, Jan 5, 2006
    #1
    1. Advertising

  2. Jarod

    Jarod Guest

    > 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
    Jarod, Jan 5, 2006
    #2
    1. Advertising

  3. Jarod

    Lee Guest

    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.
    Lee, Jan 5, 2006
    #3
  4. Jarod

    Jarod Guest

    >>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
    Jarod, Jan 5, 2006
    #4
  5. Jarod

    Lee Guest

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

    >
    >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()?
    Lee, Jan 5, 2006
    #5
  6. Jarod

    VK Guest

    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).
    VK, Jan 5, 2006
    #6
  7. Jarod

    Jarod Guest

    >> 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
    Jarod, Jan 5, 2006
    #7
  8. Jarod

    Jarod Guest

    >>>>When you delete last alert the xmlDoc in older browser will be empty
    >>>:mad: 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
    Jarod, Jan 5, 2006
    #8
  9. Jarod

    VK Guest

    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.
    VK, Jan 5, 2006
    #9
  10. Jarod

    Jarod Guest

    > 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
    Jarod, Jan 5, 2006
    #10
  11. "Jarod" <> 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 -
    DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
    'Faith without judgement merely degrades the spirit divine.'
    Lasse Reichstein Nielsen, Jan 6, 2006
    #11
  12. Jarod

    Jarod Guest

    >>> 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
    Jarod, Jan 6, 2006
    #12
  13. Jarod

    VK Guest

    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.
    VK, Jan 6, 2006
    #13
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Malik Asif Joyia

    How to send email Alerts Automatically?

    Malik Asif Joyia, Jul 7, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    3,104
    Curt_C [MVP]
    Jan 7, 2005
  2. Guest
    Replies:
    4
    Views:
    878
    Eliyahu Goldin
    Jan 4, 2005
  3. Luis Esteban Valencia

    Send Alerts to web clients?

    Luis Esteban Valencia, Jan 12, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    538
    Steve C. Orr [MVP, MCSD]
    Jan 12, 2005
  4. thatsMaBoy
    Replies:
    5
    Views:
    421
    thatsMaBoy
    Mar 13, 2007
  5. Replies:
    5
    Views:
    133
    One Dumm Hikk
    Jul 19, 2007
Loading...

Share This Page