I want to put the answer from jquery's $ .ajax () method on the target <div> inside the loading popup

I am calling ActionMehod using jquery.ajax () function and I want to put the response in a target DIV tag defined inside Bootstrap PopupModal.

$.ajax({
    type: "GET",
    data: { "id": idVal },
    contentType : "application/json",
    url: '@Url.Action("GetAssetCalcert", "SiteReport")',
    target: "#popupModel",
    success: ShowPopup()
});

function ShowPopup() {
    $('#myModal').modal('show')
    $("#loadCalcert").attr('data-toggle', 'modal');
}

      

Here "#myModal"

is the BootstrapModal id and "#popupModel"

is the DivID inside the modal body tag.

This actually makes the call to actionMethod succeed, and I get the HTML response as acknowledged when executed console.log(data)

on success. But Opens an empty popupModal and does not pass what is received.

What am I missing here?

+3


source to share


1 answer


You need to pass the return value from success to the function if you want to put it in the modal:



$.ajax({
    type: "GET",
    data: { "id": idVal },
    contentType : "application/json",
    url: '@Url.Action("GetAssetCalcert", "SiteReport")',
    target: "#popupModel",
    success: function(result) { 
      ShowPopup(result);
    }
});

function ShowPopup(result) {
    $('#myModal').html($(result).text());
    $('#myModal').modal('show')
    $("#loadCalcert").attr('data-toggle', 'modal');
}

      

+6


source







All Articles