Skip to content

Commit

Permalink
beginning the ajax and sinon lesson
Browse files Browse the repository at this point in the history
  • Loading branch information
ngauthier committed Sep 8, 2012
1 parent e060991 commit 92fc876
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion source/projects/javascript/index.md
Expand Up @@ -20,7 +20,8 @@ title: Javascript
1. [JSTasker](jquery/jstasker.html)
1. [JSCart](jquery/jscart.html)

## Javascript Testing and Ajax
## Javascript Testing and AJAX

1. [Introduction to Jasmine](testing/1-jasmine-intro.html)
1. [AJAX and Sinon.js](testing/2-ajax-and-sinon.html)

20 changes: 20 additions & 0 deletions source/projects/javascript/testing/2-ajax-and-sinon.md
@@ -0,0 +1,20 @@
---
layout: page
title: AJAX and Sinon.js
---

Javascript really gets its strengths from creating dynamic web pages, and a necessary component of that is AJAX. AJAX stands for Asynchronous Javascript and XML, and it is a technique which uses javascript to fetch data from a web server. It happens asynchronously, which means you can continue to run javascript code while the request is still pending. The XML part was the original use of AJAX, but nowadays people use all kinds of content-types as the return value from the server. The most common is JSON (Javascript Object Notation) but HTML is often used when it's simply some dynamic template data that should be inserted into the DOM.

## AJAX Basics

### XHR

XHR (XML HTTP Request) is the browser's implementation of asynchronous data requests. It's the "raw layer" like canvas that is part of a browser's native library. Like cavnas, it has a lot of low-level functions that are a bit painful to use, and it also has slightly different implementations across different browsers.

We aren't going to cover XHR, as very few projects ever deal with it directly.

### $.ajax

jQuery is the ultimate library for cross-browser compatibility, and it contains some great methods for making ajax requests. Here is an example ajax call to POST data to a server:


0 comments on commit 92fc876

Please sign in to comment.