﻿/*
* Ajax Helper Mixaroo Library
* 
* To wrap and simplify, for example, the addition of ajax queue handlers
* and global management 
*/

/*
* JSLint Configuration:
*/
/*global jQuery, $, Typekit, document, console */
mx.ajax = (function () {

    return {
        // Initialization Script
        init: function () {
            return true;
        },

        post: function (url, data, onSuccess, onError) {
            jQuery.ajax({
                url: url,
                type: "post",
                contentType: "application/x-www-form-urlencoded",
                data: data,
                success: function (data, status) {
                    if (typeof onSuccess === 'function') {
                        onSuccess(data, status);
                    }
                },
                error: function (xhr, desc, err) {
                    mx.log("Ajax Error: [DESC: " + desc + "][" + err + "]");
                    if (typeof onSuccess === 'function') {
                        onError(xhr, desc, err);
                    }
                }
            });
        }
    };
} ());

