function not working without alert

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sharon

    function not working without alert

    Hi!
    I have this function to add some parameters to my XSL and then
    retransform my XML with it, resulting in a neatly filtered table. It
    works great, but as soon as I take out the alert, it doesn't do
    anything anymore, seemingly. This is the function:

    function renderData(filt erField, filterValue, mode)
    {
    try
    {
    var s=new ActiveXObject(' MSXML2.FreeThre adedDOMDocument ');
    var x=document.XMLD ocument;
    if (x==null)
    {
    x=navigator.XML Document;
    if (mode=="pos"){s .load("/lib/xtable/xTablepos.xsl") }
    else if (mode=="neg"){s .load("/lib/xtable/xTableneg.xsl") };
    }
    else {
    if (mode=="pos"){s .load("/lib/xtable/xTablepos.xsl") }
    else if (mode=="neg"){s .load("/lib/xtable/xTableneg.xsl") };
    }
    with (new ActiveXObject(' MSXML2.XSLTempl ate'))
    {
    alert("here");
    stylesheet=s;
    with (createProcesso r())
    {
    addParameter('f ield1',filterFi eld);
    addParameter('f ilter1',filterV alue);
    input=x;
    transform();
    with (document.open( 'text/html'))
    {
    write(output);
    navigator.XMLDo cument=x;
    navigator.XSLDo cument=s;
    close();
    }
    }
    }
    }
    catch(exception )
    {
    }
    }

    I know that the problem lies with loading the XSL, because the alert
    only makes it work when it is placed either right before the "with(new
    ActiveXObject.. .) statement or right after it, before the
    stylesheet=s; statement. The extra time for the alert is obviously
    needed to load the xsl, without that extra time nothing happens. Now I
    want the thing to work WITHOUT the alert, does anyone know how I can
    make sure the XSL loads properly and then continue with the rest of
    the function? Hope someone can help me! Thanks, Sharon
  • Java  script  Dude

    #2
    Re: function not working without alert

    <snip>[color=blue]
    > I have this function to add some parameters to my XSL and then
    > retransform my XML with it, resulting in a neatly filtered table. It
    > works great, but as soon as I take out the alert, it doesn't do
    > anything anymore, seemingly. This is the function:[/color]
    </snip>

    I can't tell by looking at the code but you may be able to debug this
    further. Dumping to a console window is the best option for scripting
    language testing.

    If you have not tried this type of debugging with your code, do the
    following:
    Open a new window and do document writes to that new window from
    points in your code. Dump any values, lengths etc into the output.

    This will at least point you to where and when the problem is
    happening.

    JsD

    Comment

    Working...