jxycms
10/10/2018 - 2:54 AM

Ajax sample

$.ajax({
    url: '/Account/Login',
    type: 'POST',
    contentType: 'application/json; charset=utf-8',
    data: JSON.stringify(loginInfo),
    dataType: 'json',
    success: function (output) {
        if (output.Status == 'fail') {
            hideProgress();
            $('#btnLogin').hideProgress();
            $('#btnLogin').showValidator(output.Message, 'error', msgPosition, true);
            $('#btnLogin').html(loginText);
        }
        else {
            $('#btnLogin').html('Authenticated');
            if (window.location.search.substr(0, 11) == '?ReturnUrl=') {
                window.location = decodeURIComponent(window.location.search.slice(11));
            }
            else
                window.location.reload();
        }
    },
    error: function (request, status, error) {
        hideProgress();
        $('#btnLogin').hideProgress();
        $('#btnLogin').html(loginText);
        $('#btnLogin').showValidator(error, 'error', msgPosition, true);
    }
});

$.ajax({
    type: "GET",
    url: 'api/Checkout/GetPartnerByMPNId?mpnId=' + mpnId,
    async: false,
    success: function (data) {
        if (data.result != 'Success') {
            $('#tenant_next').showValidator(data.info, 'error');
            isValid = false;
        }
    }
});