2 Replies Latest reply on Jun 16, 2006 1:13 PM by BKBK

    scheduled task / javascript / xml

    Gakusei
      OK, here's the deal.

      I use a javascript to generate a key and and ID for use with an external xml feed. To consume the xml, I use CFHTTP call from within a CF template. But since the only way (or at least so I think) to pass a javascript variable to CF is via a javascript document.location.href redirect (and passing the variables via URL variables), I have the javascript in the first page redirect and send the variables to the coldfusion template that then digests the xml and does a database insert.

      Of course it works great in a browser, but when I attempt to use a scheduled task to run it, the cfadmin says that it runs successfully, but there's no db insert.

      I'm figuring that it's because there's no real "document" window to redirect... so how can I solve my problem?

      HELP!!!

      Thanks in advance,

      bill
        • 1. Re: scheduled task / javascript / xml
          SafariTECH Level 1
          You can't do a redirect in a scheduled app - it has to be self contained. I'm not even certain JS runs in a scheduled app, because of the fact it runs browser-less and server-side only, so it can't rely on tech built into a browser normally.


          You can do pretty much anything in CF that JS can do, so why not generate the key and ID with CF instead, and keep it self contained?

          • 2. Re: scheduled task / javascript / xml
            BKBK Adobe Community Professional & MVP
            But since the only way (or at least so I think) to pass a javascript variable to CF is via a javascript document.location.href redirect (and passing the variables via URL variables), I have the javascript in the first page redirect and send the variables to the coldfusion template that then digests the xml and does a database insert.
            You should just do a server-side redirect and avoid Javascript altogether. As a rule of thumb, one should use Javascript to manipulate data or presentation at the client end.