﻿// Provides Ajax service behavior using JQuery
function AjaxService(url, useDefaultErrorHandler) { this.url = url; this.useDefaultErrorHandler = useDefaultErrorHandler == undefined ? true : useDefaultErrorHandler; }
// Calls a service method asynchronously using JQuery Ajax
AjaxService.prototype.callMethod = function(method, bundledArguments, success, errorHandler) {
    $.ajax({ type: "POST", url: this.url + '/' + method, data: JSON.stringify(bundledArguments), contentType: "application/json; charset=utf-8", dataType: "json", 
                success: function(result, status) { if (success) success(result.d, status); },
			error: function(xhr, status, error) { if (errorHandler) errorHandler(xhr, status, error); else alert(xhr.responseText); } });
}
// Formats a date suitable for sending to a service.
function formatServiceDate(date) { return date.getMonth() + 1 + '/' + date.getDate() + '/' + date.getFullYear(); }

