Book Image

Jasmine Cookbook

By : Munish Kumar
Book Image

Jasmine Cookbook

By: Munish Kumar

Overview of this book

Table of Contents (16 chapters)
Jasmine Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Writing Jasmine specs for AJAX


Using AJAX, we can load data in the background and display it on the web page without reloading the whole page. Whenever an AJAX request is initiated, it creates an XMLHttpRequest object and sends an HttpRequest request to the server. The server processes the request and sends the response back to the browser. In other words, AJAX allows web applications to send/retrieve data to/from a server asynchronously without interfering with the display and behavior of the existing page. It is hard to test asynchronous processes. However, the Jasmine library provides a couple of tools for handling AJAX calls. In this recipe, you will learn how to write Jasmine specs for AJAX calls.

Getting ready

Now, to write Jasmine specs for AJAX, let's consider the following HTML code:

<!DOCTYPE html>
<html>
<head>
<script src="myJavaScript_File.js"></script>
</head>
<body>
<div id="myID"></div>
</body>
</html>

In the preceding...