JQuery with Ajax

JQuery with Ajax

Hi ,

I am trying to call a ajax action on button click. But the ajax call is happening multiple times which is expected to happen only once.

This issue is happening only when list of tables (whose data to be exported in excel) is more then 30 tables. The ajax call is called again approx every 3 minutes repeatedly.

Please help me to solve this issue

code template is as below :-

$("#btn").click(function(){
var selectedValues = $('#tableNameList').val(); // list of tables of which data have to export
$.ajax({
    type: 'POST',
    url: "${createLink(action:'exportData', controller:'Wizard')}/?tableList="+selectedValues,
    success: function(response, textStatus, jqXHR){
var obj = response
$("#exptbtn").removeAttr("disabled");
        },
        error: function(xhr, statusText, errorThrown){
        $("#btn").removeAttr("disabled");
        $("#messagetxt").text("Export Failed");
        $("#message").show();
        }
});
});