﻿function sendAjaxRequest(param, listener) {
    $.ajax({
        type: "POST",
        dataType: "html",
        url: PUrl,
        data: param,
        success: function(data) {
            $(listener).trigger('tareaExitosa', [data]);
        },
        error: function() {
            $(listener).trigger('ErrordeServidor', [data]);
        },
        beforeSend: function() {
            $(listener).html(msjespera);
        }
    });
}
function PostBackC(valor, obj, obj2) {
    var idob = '#' + obj;
    $(idob).bind("tareaExitosa", function(event, data) {
        $(idob).html(msjreportado);
        $(idob).animate({
            "opacity": 0.5, "margin": "5px"
        }, "slow");
        if ($('#' + obj2) != null) {
            setTimeout(function() { $('#' + obj2).animate({ "opacity": 0.0 }, "fast"); }, 2000);
            setTimeout(function() { $('#' + obj2).hide() }, 3000);
        }
    }).bind("ErrordeServidor", function(event, data) {
        $(idob).html('Error');
    });
    var param = 'c=' + valor;
    sendAjaxRequest(param, idob);
}