ajax cron jobs
play

Ajax & cron jobs Dr. Steven Bitner AJAX (Asynchronous - PowerPoint PPT Presentation

Ajax & cron jobs Dr. Steven Bitner AJAX (Asynchronous JavaScript and XML) So far in this course All of our interactions have been server side or client side AJAX blurs the lines a bit AJAX Change out part of a page Policy


  1. Ajax & cron jobs Dr. Steven Bitner

  2. AJAX (Asynchronous JavaScript and XML)

  3. So far in this course…  All of our interactions have been server side or client side  AJAX blurs the lines a bit

  4. AJAX

  5. Change out part of a page

  6. Policy  Can only perform local AJAX calls  You can however override subdomain blocking  e.g. by defualt www.mysite.com cannot make AJAX calls to info.mysite.com but that setting can be changed.

  7. First steps  First, you need JavaScript to create an object  jQuery can do this for you  Great because it handles cross browser issues related to the different object types in IE vs Chrome etc.  This object is an HTTP request object that goes to a specified url  in jQuery, via the ajax, load, get or post method – we'll talk about load since it is sufficient for all that we have learned

  8. Load  For loading a web page directly into a page element  Requires result to be text or html $("button").click(function(){ $("#myDiv").load("mydiv.php"); });

  9. Partial load  You can also load only a portion of the returned data $( "#myDiv").load("mydiv.php #someDiv");

  10. Sending a GET type request  For loading a static page where no arguments are needed $("button").click(function(){ $("#myDiv").load("mydiv.php?" + "username=bitners" + "&show=Always Sunny in Philidelphia"); });

  11. Sending a POST type request  For loading a static page where no arguments are needed $("button").click(function(){ $("#myDiv").load("mydiv.php", { username:"bitners", show:"Always Sunny in Philidelphia" }); });

  12. Cron

  13. Cron jobs  Some tasks just need to be completed regularly  Daily status report for your website  How many new users  How many downloads of particular files etc.  Weekly email blast to followers

  14. Cron is the way  Linux/Unix has a built in utility for this  Controlled by a text file called crontab

  15. Crontab fields Minute of execution 1. Hour of execution (24 hour) 2. Day of execution 3. Month of execution 4. Day of the week (0 => Sunday, 6 => Saturday) 5. File to run 6.

  16. Crontab example line  30 0 * * * emailBlast  This would run the job at midnight thirty every day of every month  59 23 * * 0,6 weekend  This would run weekend every Saturday and Sunday at one minute before midnight  cd /home/faculty/bitners/public_html && mailer  To run a PHP script, must first call executable, e.g. /usr/bin/php mailer.php

  17. Editing the crontab file  Just type `crontab – e` at the command prompt in puTTY  This will open the file for editing

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend