sheikh-k
3/22/2017 - 3:23 PM

Loading Partial view in Ajax (Helper Method).js

// LOADING PARTIAL VIEW using Ajax (Helper Method)
function loadLink(url, id) {
    if (typeof (id) === 'undefined') {
        loadPartialView(url, 'mainContent');
    } else {
        loadPartialView(url, id);
    }
}

function loadPartialView(link, position) {

    $('#' + position).html('');
    $.ajax({
        url: link,
        contentType: 'application/html; charset=utf-8',
        type: 'GET',
        async: false,
        dataType: 'html',
        beforeSend: function () {
            Spiner.show();
        }
    }).success(function (result) {
            $('#' + position).show();
            $('#' + position).html(result);
            Spiner.hide();
        }).error(function (status) {
            alert(status);
            Spiner.hide();
        });
}