I have an AJAX call that I only what to make if I've moused over a certain element for 2 seconds and to NOT make the call otherwise. I've tried to use setTimeout but it makes the call anyways. How can I achieve this?
Here is my code:
$('tr').mouseenter(function(){
    $( this ).next("#ticket_summary").show();
    var context = $( this ).next("#ticket_summary");
    var ticket_id = $( this ).next("#ticket_summary").data("id");
    var url = "/support/ticket_description/" + ticket_id.toString();
    console.log(url);
    setTimeout(function(){
    $.ajax({
        url: url,
        type: "GET",
        dataType: "json",
        success: function(data) {
            context.find('#ticket_summary_description').html(data[1]['fields']['text']);
            context.find('#ticket_summary_last_comment').html(data[2]['fields']['text']);
        },
        error: function(data) {
            context.find('#ticket_summary_description').html('error');
            context.find('#ticket_summary_last_comment').html('error');
        }
    });
    }, 2000);
});
 
     
     
    