$ajaxUtils is not included in jQuery.js
To resolve this, create a new file named ajax-utils.js and include the following code:
(function(global) {
// Create namespace for utility
var ajaxUtils = {};
// Function to return an HTTP request object
function getRequestObject() {
if (window.XMLHttpRequest) {
return (new XMLHttpRequest());
}
else if (window.ActiveXObject) {
// For old IE browsers
return (new ActiveXObject("Microsoft.XMLHTTP"));
}
else {
global.alert("Ajax is not supported!");
return(null);
}
}
// Sends an Ajax GET request to 'requestUrl'
ajaxUtils.sendGetRequest =
function(requestUrl, responseHandler, isJsonResponse) {
var request = getRequestObject();
request.onreadystatechange =
function() {
handleResponse(request,
responseHandler,
isJsonResponse);
};
request.open("GET", requestUrl, true);
request.send(null); // for POST only
};
// Calls user provided 'responseHandler' only if response is ready and not an error
function handleResponse(request,
responseHandler,
isJsonResponse) {
if ((request.readyState == 4) &&
(request.status == 200)) {
// Default to isJsonResponse = true
if (isJsonResponse == undefined) {
isJsonResponse = true;
}
if (isJsonResponse) {
responseHandler(JSON.parse(request.responseText));
}
else {
responseHandler(request.responseText);
}
}
}
// Expose utility globally
global.$ajaxUtils = ajaxUtils;
})(window);
Remember to link ajax-query.js to your index.html page :)