When I make an AJAX call the page refreshes - why?

Viewed 100

I am going to load a data table which contains some data along with one image in each row. When clicking on that image I am going to call DraftView() which contains an AJAX call. After getting a response, the modal is going to popup and the page is going to reload so I don't want to reload.

enter image description here

This is the image loaded in a jQuery datatable

<img height="30%" width="50%" src="/Content/Images/other/dview.png"  onclick="DraftView(this); return false;" />

This is my function

function DraftView(ref) {
  var row = $(ref).closest("tr");
  var data = $('#tblDigitalSigningList').dataTable().fnGetData(row);
  var rdno = data.RDNO;
  
  var Records_Table = new Array();  
  var List = {};
  List.RDNO = data.RDNO;
  List.HobliCode = $("#DdlHobli").val();
  List.FacilityCode = $("#DdlServices").val();
  Records_Table.push(List);
  
  $.ajax({
    type: "POST",
    url: "/DigitalSigningRIDifferDetails/DraftView",
    data: JSON.stringify(Records_Table),
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function(response) {
      var options = {
        "backdrop": "static",
        keyboard: true
      };
      
      $.get('/DataLoad/LoadDraftView', function(html) {
        // insert your html into the DOM
        $('#myModalContentDraftView').html(html);
      });
      
      $('#myModalDraftView').modal(options);
      $('#myModalDraftView').modal('show');
    }
  })
}
0 Answers
Related