﻿function WebService(url, callback, params) {
    $.ajax({
        data: params,
        url: url,
        type: "POST",
        contentType: "application/json;utf-8",
        dataType: 'json',
        cache: false,
        success: function(json) {
            callback(json);
        },
        error: function(xml, status) {
            if (status == 'error') {
                try {
                    var json = eval('(' + xml.responseText + ')');
                    alert(json.Message + '\n' + json.StackTrace);
                } catch (e) { }
            } else {
                alert(status);
            }
        },
        beforeSend: function(xml) {
            if (!params) xml.setRequestHeader("Content-Type", "application/json;utf-8")
        }
    });
}
