Jquery ajax button click event firing twice? Jquery ajax button click event firing twice? ajax ajax

Jquery ajax button click event firing twice?


You call $.ajax twice.

At lines

$.ajax(options).success(function(data)...$.ajax(options).error(function(data)...

you actually make two different AJAX calls - one with success callback only, another one with error callback.

In your case, your call should look like this:

var options = {    type: "GET",    url: href,    data: { menuRoleId: menuRoleId }};$.ajax(options)    .success(function (data) {        spinner.toggle(false);        $(".modal-body").html(data);        $(".modal").modal({            backdrop: 'static'        });    })    .error(function (data) {        spinner.toggle(false);        toastr.error("Oops..Some thing gone wrong");    });return false;

It will set both callbacks to the single AJAX call and execute this one.