Javascript and Crons

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chazzy69
    New Member
    • Sep 2007
    • 196

    Javascript and Crons

    Hi all not sure where to post this question but here it is anyway-

    I have a page on my webserver we i view it manually in my browser i can use javascript to automatically actuate a form, i.e. it automatically posts a form to another webpage when it is loaded.

    This is a .php page so when the script runs it automatically post this form to another .php which recieves it then process the information.

    Now what i want to know is it possible for the javascript on the .php page to work when i run a cron job, cause when i tried it ran the page but didn't seems to run the script.
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Does the cron use a browser to open the page?

    Comment

    • rnd me
      Recognized Expert Contributor
      • Jun 2007
      • 427

      #3
      php doesn't run javascript.

      you could write a wrapper page and use javascript to resubmit the form on a timeout instead of a chron job.

      in win xp, the page can run 24/7 by making it a new active desktop item.

      Comment

      • chazzy69
        New Member
        • Sep 2007
        • 196

        #4
        Sorry for the slow reply got a little distracted,

        Anyway the cron does not use a browser, its run by the server;

        Also do u know of any php functions that can actuate a button on an event such as a timer.

        The idea is the cron job runs the .php page after 20 seconds or so it will imitate someone clicking a button.


        Thanks for the help,

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          Why not have a browser window open and use setInterval to simulate clicking the button every 20 seconds?

          Even if you use PHP to generate some client-side code, PHP is run on the server, so you can't do this with PHP alone.

          Comment

          • chazzy69
            New Member
            • Sep 2007
            • 196

            #6
            You see i don't mind using something else as well it just that when i run the cron job it won't use the javascript code (not a browser), not sure about other scripts though.

            How would i open a browser page on a remote server (the one the script is being hosted on).

            And can u give a reference for "setinterva l" is it a php function??

            Thanks heaps

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

              #7
              setInterval is a JavaScript function. I meant manually opening the browser on the remote server and then letting it run continuously. Is that an option or are you running it from somewhere else?

              A question you could ask yourself is is the JavaScript necessary and can you do without. Can you post the JavaScript code on the page?

              Comment

              • chazzy69
                New Member
                • Sep 2007
                • 196

                #8
                I believe i have found a solution purely with php,

                Thanks for all help

                Comment

                • acoder
                  Recognized Expert MVP
                  • Nov 2006
                  • 16032

                  #9
                  Glad you found a solution. Makes sense really to go with PHP alone in this case.

                  Comment

                  Working...