From 083bb80a8c09788ac5d313b5def52f5c55c2efb3 Mon Sep 17 00:00:00 2001 From: Matt Huntington Date: Sun, 6 May 2018 15:15:37 -0400 Subject: [PATCH] ajax --- ajax/basics.md | 182 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 181 insertions(+), 1 deletion(-) diff --git a/ajax/basics.md b/ajax/basics.md index a12c8fa..d60b059 100644 --- a/ajax/basics.md +++ b/ajax/basics.md @@ -1 +1,181 @@ -includes CORS, JSONP +# Javascript - AJAX + +## Lesson Objectives + +1. Explain AJAX +1. Demonstrate jQuery AJAX +1. Explain promises +1. Explain Cross Site AJAX +1. Explain JSONP +1. Explain CORS + +## Explain AJAX + +## Demonstrate jQuery AJAX + +```html + + + + + + + + hi + + + +``` + +## Explain promises + +```html + + + + + + + + + + +``` + +more succinct with extra done: + +```html + + + + + + + + + + +``` + +custom deferred and promise objects: + +```html + + + + + + + + + + +``` + +## Explain Cross Site AJAX + +```javascript +$.ajax({ + url: 'https://status.github.com/api/status.json', + success: function(data) { console.log(data) }, + error: function(jqXHR, status, errorThrown){ console.log(status); } +}); +``` + +look at console + +## Explain JSONP + +```html + + + + +``` + +## Explain CORS + +1. http://www.omdbapi.com/?s=pirates&r=json +1. `Access-Control-Allow-Origin:*`