This shows you the differences between two versions of the page.
tutorials:zencartmods:daily_ajax.html [2011/06/22 15:21] daigo created |
tutorials:zencartmods:daily_ajax.html [2016/01/28 18:05] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ==== AJAXify your Daily stats ==== | ||
- | |||
- | Last week, we created a [[daily_stats.html| daily stats]] page. If you're like us, then you compulsively click refresh on this page way too often! So lets AJAX-ify this page so that it updates automatically every time someone makes an order. | ||
- | |||
- | === Get jQuery === | ||
- | |||
- | We're going to use jQuery for this page. [[http://jquery.com/|jQuery\]] isn't necessary for AJAX, you could just use plain javascript as well, but jQuery makes things much easier in general. | ||
- | |||
- | You can either [[http://docs.jquery.com/Downloading_jQuery#Download_jQuery|download jQuery]] and host it on your own server, or use a CDN like Google or Microsoft. We use Google's CDN. | ||
- | |||
- | |||
- | If you're hosting it on your own server, then add to the **<head>** section of daily stats | ||
- | <code> | ||
- | <script src="https://you.path/to.jquery.js"></script> | ||
- | </code> | ||
- | |||
- | or if you're using a CDN (this one is Google) then use | ||
- | <code> | ||
- | <script type="text/javascript" src="https://www.google.com/jsapi?key=YOUR_API_KEY"></script> | ||
- | <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> | ||
- | </code> | ||
- | |||
- | you have to replace YOUR_API_KEY with the API key you've obtained from Google. | ||
- | |||
- | |||