AJAX
logo

Preparation

Mozilla Developer Network (MDN)’s Web technology for developers: Ajax

Learning Objectives

  • Use Ajax to modify the content of a web page to display data retrieved from a web server without reloading the page
  • Compare and contrast GET and POST requests

Practice

Ajax

Open the books example. Search for a book in the “database” by entering an ISBN number. (Hint: Try the ISBN of the textbook.) Can you find the use of Ajax by viewing the source of the web page?

JavaScript Regular Expressions

Open W3Schools’s JavaScript RegExp Reference and regex101.com in separate browser windows. Select “ECMAScript (JavaScript)” as the regular expression flavor (you may need to expand the regex101.com window to see this option).

Write a regular expression to describe a phone number of the form N-XXX-XXX-XXXX where N can only be a zero or a one. Look up the meaning of ^ and $, and enclose your regular expression in parentheses to delineate a “match group.” Do not permit 1-456-345-5678xxx to be accepted.

Note: When entering a regular expression in JavaScript, you must always double the backslashes. For example, consider how to match three digits:

var pattern = new RegExp("(\\w\\w\\w)", "");
pattern.test(value);

is correct whereas

var pattern = new RegExp("(\w\w\w)", "");
pattern.test(value);

is invalid.