﻿/// <reference path="jquery-1.4.1.js" />

function LoadToContainer(targetContainer, method, targetAction, onSuccess, onError) {
    AjaxCall(targetAction, null, method, null, false, function (data) {
        $(targetContainer).html(data);
        if (onSuccess != null) {
            try 
            {
                onSuccess();
            }
            catch (e) 
            {
            }
        }
    }, onError);
}

function GetJsonResult(data) {
    return eval(data.get_response().get_object());
}

function GetResponseData(data) {
    if (data.get_response().get_responseAvailable()) {
        return data.get_response().get_responseData();
    }
}

function ExecuteAction(targetAction, data, method, dataType, onSuccess, onError)
{
    AjaxCall(targetAction, data, method, dataType, false, onSuccess, onError);
}

function AjaxCall(url, sendData, method, dataType, cache, onSuccess, onError)
{
    $.ajax({
        url: url,
        data: sendData,
        type: method,
        cache: cache,
        error: onError,
        success: onSuccess,
        dataType: dataType
    });
}


