27.10.2015 Views

AJAX and PHP

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Client-Side Techniques with Smarter JavaScript<br />

Let's do a short exercise.<br />

Time for Action—Playing with JavaScript <strong>and</strong> the DOM<br />

1. Create a folder called foundations in your ajax folder. This folder will be used for<br />

all the examples in this chapter <strong>and</strong> the next chapter.<br />

2. In the foundations folder, create a subfolder called jsdom.<br />

3. In the jsdom folder, add a file called jsdom.html, with the following code in it:<br />

<br />

<br />

<br />

<strong>AJAX</strong> Foundations: JavaScript <strong>and</strong> DOM<br />

<br />

<br />

<br />

I love you!<br />

<br />

<br />

4. In the same folder create a file called jsdom.js, <strong>and</strong> write this code in the file:<br />

// declaring new variables<br />

var date = new Date();<br />

var hour = date.getHours();<br />

// demonstrating the if statement<br />

if (hour >= 22 || hour

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!