forked from dytcodetogether/gdi-intermediate-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
class4.html
692 lines (607 loc) · 25.6 KB
/
class4.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Intermediate JavaScript</title>
<meta name="description" content="Girl Develop It framework for easily creating beautiful presentations using HTML in GDI theme. Forked from Hakim El Hattab's reveal.js">
<meta name="author" content="Girl Develop It">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/simple.css" id="theme">
<!-- For syntax highlighting -->
<!-- light editor --><link rel="stylesheet" href="lib/css/light.css">
<!-- dark editor <link rel="stylesheet" href="lib/css/dark.css">-->
<!-- <link rel="stylesheet" href="lib/css/zenburn.css"> -->
<link rel="stylesheet" href="plugin/accessibility-helper/css/accessibility-helper.css">
<!-- If the query includes 'print-pdf', include the PDF print sheet -->
<script>
if( window.location.search.match( /print-pdf/gi ) ) {
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = 'css/print/pdf.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
}
</script>
<!-- If use the PDF print sheet so students can print slides-->
<link rel="stylesheet" href="css/print/pdf.css" type="text/css" media="print">
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<!-- AJAX and JSON -->
<section>
<h1>JSON & AJAX</h1>
</section>
<section>
<h3>JSON</h3>
<ul>
<li class="fragment">JSON = JavaScript Object Notation</li>
<li class="fragment">A set of key/value pairs</li>
<li class="fragment">Keys must be stored in quotes</li>
<li class="fragment">Values can be Number, String, Boolean, Array, Object or null</li>
<li class="fragment">Resembles objects, hash tables, or structs of programming languages</li>
<li class="fragment">Can be validated at <a href="http://jsonlint.com/" target="_blank">JSONlint.com</a></li>
</ul>
<aside class="notes">
<ul>
<li>JSON = JavaScript Object Notation</li>
<li>A set of key/value pairs</li>
<li>Keys must be stored in quotes</li>
<li>Values can be Number, String, Boolean, Array, Object or null</li>
<li>Resembles objects, hash tables, or structs of programming languages</li>
<li>Can be validated at <a href="http://jsonlint.com/" target="_blank">JSONlint.com</a></li>
</ul>
</aside>
</section>
<section>
<h3>Example JSON</h3>
<pre><code class="javascript">{
"firstName": "Jane",
"lastName": "Smith",
"address": {
"streetAddress": "425 2nd Street",
"city": "San Francisco",
"state": "CA",
"postalCode": 94107
},
"phoneNumbers": [
"212 732-1234",
"646 123-4567" ]
}</code></pre>
<aside class="notes">
<ul>
<li>Notice the "" for all the attribute names</li>
<li>JSON supports two widely used (amongst programming languages) data structures:</li>
<li>A <strong>collection of name/value pairs.</strong></li>
<li>An ordered list of values</li>
<li>Since data structure supported by JSON is also supported by most of the modern programming languages data-interchange format.</li>
</aside>
</section>
<section>
<h3>Moving JSON to the DOM</h3>
<p>Start by storing JSON in a variable:</p>
<pre><code class="javascript">var myProfile = {
"firstName": "Natalie",
"lastName": "MacLees",
"cats": ["Mabel", "Ollie"]};</code></pre>
<p>Then, you can access the data stored inside and use it while creating new nodes:</p>
<pre><code class="javascript">var p = document.createElement('p');
p.innerHTML = 'My name is ' + myProfile.firstName + ' ' + myProfile.lastName + '. ';
p.innerHTML += 'My cats are ' + myProfile.cats.join(' and ') + '.';
var body = document.getElementsByTagName('body')[0];
body.appendChild(p);</code></pre>
<a href="http://bit.ly/intermediate-js-json-dom" target="_blank">http://bit.ly/intermediate-js-json-dom</a>
</section>
<section>
<h3>Let's Develop It!</h3>
<p><a href="files/exercise-videoplayer.html" target="_new">Exercise instructions</a></p>
<p><a href="http://bit.ly/intermediate-js-class-4-ex-1" target="_blank">http://bit.ly/intermediate-js-class-4-ex-1</a></p>
<p>
Note: to get json files in your codepen.io
<ol>
<li>
Open Settings
</li>
<li>
Go to JavaScript
</li>
<li>
Add the url to "Add External JavaScript"
</li>
</ol>
</p>
</section>
<section>
<h2>Questions?</h2>
<p>Questions about JSON?</p>
</section>
<section>
<h3>Ajax</h3>
<p>Asynchronous JavaScript And "XML"</p>
<img src="img/ajax.png" height="400" width="600" alt="">
<aside class="notes">
<ul>
<li>Client is your machine/browser</li>
<li>JavaScript</li>
<li>Eventhandler is our listener</li>
<li>Callback function we write</li>
<li>Manipulates the DOM elements on the webpage</li>
<li>During our event handling we can call out to the server with <strong>XMLHttpRequest</strong></li>
</ul>
</aside>
</section>
<section>
<h3>Ajax in the wild</h3>
<img src="img/wild-ajax.png" height="880" width="1136" alt="">
<aside class="notes">
<ul>
<li>Let's look at an example of AJAX</li>
<li>show example of ajax calls in console. <a href="https://twitter.com/gdiseattle" target="_blank">https://twitter.com/gdiseattle</a></li>
<li>Open the dev tools, go to network tab</li>
<li>Sort by XHR</li>
<li>find something with a json</li>
</ul>
</aside>
</section>
<section>
<h3>Local server</h3>
<p>We're going to start writing some ajax now.</p>
<p>If you haven't already, get a local server running.</p>
<p><a href="files/exercise-localserver.html" target="_new">Local Server Help</a></p>
</section>
<section>
<h3>Local server</h3>
<ol>
<li>Open Terminal</li>
<li>Navigate to your project directory. You can do this using the <code>cd</code> command in the terminal.</li>
<li>Run this command: <code>python -m SimpleHTTPServer</code>
<ul><li>If you are running Python 3, run this command instead: <code>python -m http.server 8000</code></li></ul>
</li>
<li>If successful, you should then be able to access your project folder by pointing your browser to http://localhost:8000</li>
</ol>
<p><a href="files/exercise-localserver.html" target="_new">Local Server Help</a></p>
</section>
<section>
<h3>The <code>XMLHttpRequest</code> object</h3>
<ul>
<li>A native JavaScript object that can communicate <span class="blue">asynchronously</span> between the client and the server.</li>
<li>To use it, we create a new instance of the object:
<pre><code class="javascript">var request = new XMLHttpRequest();</code></pre>
</li>
<li>...and then use the properties and methods of that object to make an ajax call</li>
</ul>
<p class="fragment"></br>
<strong>Asynchronous</strong> means you can move on to another task before it finishes, while <strong>synchronous</strong> means you wait for it to finish before moving on to another task.
</p>
<aside class="notes">
Make note of asynchronous v. syncronous. How this will be important
for waiting for your data to return.
</aside>
</section>
<section>
<h3>Getting ready to communicate</h3>
<p>Now that we've created an instance of the XHR object, it needs to be prepped for communication. That requires three things:</p>
<ol>
<li>The <code>readystatechange</code> event handler</li>
<li>The <code>open()</code> method</li>
<li>The <code>send()</code> method</li>
</ol>
<p></br>
<a href="https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest" target="_blank">Check out the documentation for XMLHttpRequest</a>
</p>
<aside class="notes">
These are talked about on the next slides
</aside>
</section>
<section>
<h3><code>readystatechange</code></h3>
<ul>
<li>During an ajax operation, the server sends updates to the client about the current status of the communication by updating a property of the XHR object called <code>readyState</code>.</li>
<li class="fragment">Each time the <code>readyState</code> property is changed, the <code>readystatechange</code> event is fired.</li>
<li class="fragment">If you add an event listener function to the <code>readystatechange</code> event, your function will execute each time the server pings the client with an update.</li>
</ul>
<aside class="notes">
<li>Each time the <code>document.readyState</code> property is changed, the <code>readystatechange</code> event is fired.</li>
<li>If you add an event listener function to the <code>readystatechange</code> event, your function will execute each time the server pings the client with an update.</li>
</aside>
</section>
<section>
<h3>An <code>onreadystatechange</code> example</h3>
<pre><code class="javascript">var request = new XMLHttpRequest();
if(request) {
request.addEventListener('readystatechange', function(){
console.log(request.readyState);
});
}</code></pre>
<aside class="notes">
This code doesn't do anything right now. Since there are no state changes
</aside>
</section>
<section>
<h3>The <code>open()</code> method</h3>
<div class="left-align">
<p>The <code>open()</code> method takes two required arguments:</p>
<ol>
<li>The type of request (string)</li>
<li>The location of the file on the server (string)</li>
</ol>
<pre><code class="javascript">XMLHttpRequest.open(method, url)
XMLHttpRequest.open(method, url, async)
XMLHttpRequest.open(method, url, async, user)
XMLHttpRequest.open(method, url, async, user, password)
</code></pre>
<div class="fragment">
<p > And an additional optional argument:</p>
<ol>
<li>Whether or not the request should be asynchronous (Boolean)</li>
</ol>
</div>
</div>
<aside class="notes">
<div class="left-align">
<p>The <code>open()</code> method takes two required arguments:</p>
<ol>
<li>The type of request (string)</li>
<li>The location of the file on the server (string)</li>
</ol>
<span >
<p>And an additional optional argument:</p>
<ol>
<li>Whether or not the request should be asynchronous (Boolean)</li>
</ol></span>
</div>
</aside>
</section>
<section>
<h3>The <code>open()</code> method</h3>
<pre><code class="javascript">var request = new XMLHttpRequest();
if(request) {
request.addEventListener('readystatechange', function(){
console.log(request.readyState);
});
request.open('GET', 'me.json', true);
}</code></pre>
<p>Here's a <a href="files/me.json">me.json</a> file you can include in your project to call.</p>
</section>
<section>
<h3>Request types: <code>GET</code> and <code>POST</code></h3>
<dl>
<dt><code>GET</code></dt>
<dd>
<ul>
<li>Most commonly used</li>
<li>When you just want to retrieve a file from the server and you don't need to send any data</li>
<li>Also capable of sending a small amount of data as a query string</li>
</ul>
</dd>
<dt><code>POST</code></dt>
<dd>
<ul>
<li>Useful for sending a lot of data to the server</li>
</ul>
</dd>
</dl>
<p><small>Just FYI, there are some other request types too (<code>PUT</code>, <code>DELETE</code>, and <code>HEAD</code>, for example), but they're not a concern for the stuff we're doing.</small></p>
</section>
<section>
<h3>Location of the file</h3>
<ul>
<li>A string that contains either a relative, absolute, or full path to a file on the server</li>
<li>The file you are requesting must reside in the same domain as the JavaScript file that is making the request.</li>
</ul>
</section>
<section>
<h3>Cross Domain Policy</h3>
<h4>or Same-Origin Policy</h4>
<p>If we're on this page: <a>http://store.company.com/dir/page.html</a></p>
<p>Here's how these ajax requests will work out:</p>
<table>
<thead>
<tr>
<th>URL</th>
<th>Outcome</th>
<th>Reason</th>
</tr>
</thead>
<tbody>
<tr class="success">
<td>http://store.company.com/dir2/other.html</td>
<td>Success</td>
<td></td>
</tr>
<tr class="success">
<td>http://store.company.com/dir/inner/other.html</td>
<td>Success</td>
<td></td>
</tr>
<tr class="failure">
<td>https://store.company.com/secure.html</td>
<td>Failure</td>
<td>Different protocol</td>
</tr>
<tr class="failure">
<td>http://store.company.com:81/dir/etc.html</td>
<td>Failure</td>
<td>Different port</td>
</tr>
<tr class="failure">
<td>http://news.company.com/dir/other.html</td>
<td>Failure</td>
<td>Different host</td>
</tr>
<tr class="failure">
<td>http://google.com</td>
<td>Failure</td>
<td>Different host</td>
</tr>
</tbody>
</table>
<p class="fragment">
This is to prevent malicious scripts from running on the page.
</p>
</section>
<section>
<h3>Asynchronous</h3>
<p>Indicates whether the request should occur asynchronously or not.</p>
<p>If <code>true</code>, the script will make the request and won't wait for the response from the server before moving on to the rest of the script.</p>
<p>If <code>false</code>, the browser will stop processing the script until the ajax request is completed.</p>
<h4>Use <code>true</code>!</h4>
</section>
<section>
<h3>The <code>send()</code> method</h3>
<p>Once your request is prepped by the <code>open()</code> method, it's ready to be sent!</p>
<pre><code class="javascript">XMLHttpRequest.send(body)</code></pre>
</section>
<section>
<h3><code>send()</code> using <code>GET</code></h3>
<pre><code class="javascript">var request = new XMLHttpRequest();
if(request) {
request.addEventListener('readystatechange', function(){
console.log(request.readyState);
});
request.open('GET', 'me.json', true);
request.send();
}</code></pre>
<p>Here's a <a href="files/me.json">me.json</a> file you can include in your project to call.</p>
<p>
Here is a link to the <a href="https://gist.githubusercontent.com/kcjonesevans/25d86771f45b4f4fc61f92185c473404/raw/28c65580c775243e7adb4851611c7923e233c04c/me.json" target="_blank">gist</a>
</p>
<p><a href="http://bit.ly/intermediate-js-class4-xmlhttprequest" target="_blank">http://bit.ly/intermediate-js-class4-xmlhttprequest</a></p>
</section>
<section>
<h3>The <code>readyState</code> property</h3>
<p>Indicates the current state of the Ajax request. Possible values:</p>
<img src="img/readystate.png" width="1136" alt="">
</section>
<section>
<h3><code>POST</code>: The <code>setRequestHeader()</code> method</h3>
<p>Since we're sending data with the <code>POST</code> type, we have an extra step. We need to use the <code>setRequestHeader</code> method of the XHR object to set the request headers.</p>
<p>Request headers are bits of metadata that describe the request so the server understands what to expect from the data received.</p>
<p><code>setRequestHeader()</code> takes two arguments:</p>
<ol>
<li>Name of the header (string)</li>
<li>Value of the header (string)</li>
</ol>
<pre><code class="javascript">XMLHttpRequest.setRequestHeader(header, value);</code></pre>
</section>
<section>
<h3><code>setRequestHeader()</code> example</h3>
<p>If you are sending data to the server, you need to set the value of the <code>Content-type</code> header to <code>application/x-www-form-urlencoded</code>, like this:</p>
<pre><code class="javascript">request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');</code></pre>
<p>This tells the server to expect some data and for that data to be URL-encoded.</p>
<p><span class="blue">URL-encoded</span> means spaces become plus signs (+) and non-alphanumeric characters need to be encoded as <a href="http://www.degraeve.com/reference/urlencoding.php">hex values</a>.</span></p>
<pre><code class="javascript">'name=Natalie+MacLees&message=JavaScript+is+awesome%21'</code></pre>
</section>
<section>
<h3><code>send()</code> using <code>POST</code></h3>
<pre><code class="javascript">var request = new XMLHttpRequest();
if(request) {
request.addEventListener('readystatechange', function(){
console.log(request.readyState);
});
request.open('POST', 'me.php', true);
request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
request.send('name=Natalie+MacLees&message=JavaScript+is+awesome%21');
}</code></pre>
<p>
<a href="http://bit.ly/intermediate-js-class4-post" target="_blank">http://bit.ly/intermediate-js-class4-post</a>
</p>
<p>
This code won't work with simpleserver (which does not support POST)
</p>
</section>
<section>
<h3>Let's Develop It!</h3>
<p>In your project folder, create a simple <code>.txt</code> file with a sentence of plain text in it.</p>
<p>Next, set up a new XMLHttpRequest (XHR) object and get the file. Use the console tools to view the request.</p>
</section>
<section>
<h3>Receiving a response</h3>
<p>Phew! Now we've got sending a request down - let's learn how to receive a response!</p>
</section>
<section>
<h3>The <code>readyState</code> property</h3>
<p>Indicates the current state of the Ajax request. Possible values:</p>
<img src="img/readystate.png" width="1136" alt="">
</section>
<section>
<h3><code>readyState</code> property and the <code>readyStateChange</code> event</h3>
<p>In theory, the readyState property counts from 0 to 4 in order.</p>
<p>In practice, what happens is a bit unpredictable.</p>
<p>What we <em>can</em> count on is that if the value has reached <code>4</code>, the server has finished sending a response.</p>
</section>
<section>
<h3>Checking the <code>readyState</code></h3>
<pre><code class="javascript">var request = new XMLHttpRequest();
var doSomething = function() {
if (request.readyState == 4) {
console.log('The request is complete!');
//do something with the response here
}
}
if(request) {
request.addEventListener('readystatechange', doSomething);
request.open('GET', 'me.json', true);
request.send();
}</code></pre>
<p><code>doSomething()</code> gets called every time the value of the <code>readyState</code> property changes, but our <code>if</code> statement ensures nothing will happen unless the value is <code>4</code>.</p>
<p>
<a href="http://bit.ly/intermediate-js-class4-readystate" target="_blank">http://bit.ly/intermediate-js-class4-readystate</a>
</p>
</section>
<section>
<h3>Status</h3>
<p>When the server sends back a response, it always includes response headers with metadata about the response.</p>
<p>These headers include a <span class="blue">status code</span> - a three digit number that is part of the HTTP protocol</p>
<p>Some examples:</p>
<ul>
<li><code>404</code> - not found</li>
<li><code>403</code> - forbidden</li>
<li><code>500</code> - internal server error</li>
</ul>
</section>
<section>
<h3>200 OK</h3>
<p>The most common status code is <code>200</code>, which means <code>OK</code>. It indicates the response was successfully sent.</p>
<p>The XHR object has a property called <code>status</code> where the status code is stored. We can check it to make sure we got a successful response:</p>
<pre><code class="javascript">var doSomething = function() {
if(request.readyState == 4) {
if(request.status == 200) {
console.log('The request is complete and ok.');
//do something with the response here
}
}
}</code></pre>
</section>
<section>
<h3>When things don't go as planned...</h3>
<p>We can also add an <code>else</code> statement to deal with situations where things don't go according to plan:</p>
<pre><code class="javascript">var doSomething = function() {
if(request.readyState == 4) {
if(request.status == 200) {
console.log('The request is complete and ok.');
//do something with the response here
} else {
//something went wrong
}
}
}</code></pre>
</section>
<section>
<h3>The <code>responseText</code> property</h3>
<p>The <code>responseText</code> property of the XHR object contains the data sent from the server as a string.</p>
<pre><code class="javascript">var doSomething = function() {
if(request.readyState == 4) {
if(request.status == 200) {
console.log(request.responseText);
}
}
}</code></pre>
</section>
<section>
<h3>But we need JSON!</h3>
<p>The <code>responseText</code> property contains our data, but it's a string, and we need JSON. We just need to convert it to JSON like this:</p>
<pre><code class="javascript">var jsonObj = JSON.parse(request.responseText);</code></pre>
</section>
<section>
<h3>Putting it all together</h3>
<p>Let's step through fetching some information from the server with ajax and displaying it on our page.</p>
<p>
<a href="http://bit.ly/intermediate-js-class4-all" target="_blank">http://bit.ly/intermediate-js-class4-all</a>
</p>
</section>
<section>
<h3>First, we need to create, prep, and send our request:</h3>
<pre><code class="javascript">var request = new XMLHttpRequest();
var displayResponse = function(){
// we'll write some code here later
};
if (request) {
request.addEventListener('readystatechange', displayResponse);
request.open('GET', 'me.json', true);
request.send();
}</code></pre>
</section>
<section>
<h3>Next, we need a place in our HTML to display the results:</h3>
<pre><code class="xml"><div id="resultsBox"></div></code></pre>
</section>
<section>
<h3>Then, we'll handle the response</h3>
<pre><code class="javascript">var displayResponse = function(){
if (request.readyState == 4) {
if (request.status == 200) {
var jsonObj = JSON.parse(request.responseText);
var p = document.createElement('p');
p.innerHTML = 'My name is ' + jsonObj.firstName + ' ' + jsonObj.lastName + ' and I live at ' + jsonObj.address.streetAddress + ' in ' + jsonObj.address.city + '. ';
p.innerHTML += 'My zip code is ' + jsonObj.address.postalCode + '.';
var displayBox = document.getElementById('resultsBox');
displayBox.appendChild(p);
}
}
};</code></pre>
<p>We're using what we already learned about dealing with JSON!</p>
</section>
<section>
<h3>Let's Develop It!</h3>
<p><a href="files/exercise-ajaxvideoplayer.html" target="_new">Exercise Instructions</a></p>
</section>
<section>
<h3>Ajax</h3>
<p>The <code>XMLHttpRequest</code> is the heart and soul of ajax. Its methods and properties drive the requests that make ajax feel so responsive.</p>
</section>
<section>
<h3>Things to keep in mind</h3>
<ul>
<li>Cross domain requests are restricted.</li>
<li>Multiple ajax requests don't return in the same order they were sent.</li>
</ul>
</section>
<section>
<h2>Questions?</h2>
<p>Questions about JSON or Ajax before we wrap up?</p>
</section>
<section>
<h3>Thank you!</h3>
<p>As you keep working with JavaScript, if you have questions or get stuck, post in our <a href="https://gdiseattle.slack.com">slack</a> and we'll help you out!.</p>
</section>
</div>
<footer>
<div class="copyright">
Intermediate JavaScript -- GDI Seattle --
<a rel="license" href="http://creativecommons.org/licenses/by-nc/3.0/deed.en_US"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-nc/3.0/80x15.png" /></a>
</div>
</footer>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.min.js"></script>
<script>
// Full list of configuration options available here:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
transition: 'slide', // none/fade/slide/convex/concave/zoom
// Optional reveal.js plugins
dependencies: [
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/highlight/highlight.js', async: true, condition: function() { return !!document.querySelector( 'pre code' ); }, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/zoom-js/zoom.js', async: true },
{ src: 'plugin/notes/notes.js', async: true },
{ src: 'plugin/accessibility-helper/js/accessibility-helper.js', async: true, condition: function() { return !!document.body.classList; } }
]
});
</script>
</body>
</html>