This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Next revision Both sides next revision | ||
tutorials:zencartmods:daily_ajax.html [2011/06/22 16:11] daigo |
tutorials:zencartmods:daily_ajax.html [2011/06/22 16:17] daigo |
||
---|---|---|---|
Line 11: | Line 11: | ||
If you're hosting it on your own server, then add into the **<head>** section of daily_stats.php | If you're hosting it on your own server, then add into the **<head>** section of daily_stats.php | ||
- | <code> | + | <code html> |
<script src="https://you.path/to.jquery.js"></script> | <script src="https://you.path/to.jquery.js"></script> | ||
</code> | </code> | ||
or if you're using a CDN (this one is Google) then use | or if you're using a CDN (this one is Google) then use | ||
- | <code> | + | <code html> |
<script type="text/javascript" src="https://www.google.com/jsapi?key=YOUR_API_KEY"></script> | <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> | <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> | ||
Line 27: | Line 27: | ||
At the top of **daily_stats.php**, add this code AFTER the **require('includes/application_top.php');** | At the top of **daily_stats.php**, add this code AFTER the **require('includes/application_top.php');** | ||
- | <code> | + | <code php> |
$action = $_POST['action']; | $action = $_POST['action']; | ||
Line 53: | Line 53: | ||
This will make daily_stats.php echo out 2 different JSON files, depending on post data. 'latest' will be used for polling (we can poll the server every 5, 10, 15 seconds or so) and 'stats' will be triggered by new information in the polling event. | This will make daily_stats.php echo out 2 different JSON files, depending on post data. 'latest' will be used for polling (we can poll the server every 5, 10, 15 seconds or so) and 'stats' will be triggered by new information in the polling event. | ||
+ | |||
+ | There's and **exit()** after it returns the data so that if we jsut want the JSON data, it wont continue rendering the page or anything. | ||
=== Client Side Javascript === | === Client Side Javascript === |