Method POST, Status (canceled) error message

前端 未结 6 1487
北恋
北恋 2021-02-20 04:08

I have the following code which is giving me a Method POST, Status (canceled) error message:

$(document).ready(function() {
    var xhr = false;

           


        
6条回答
  •  不知归路
    2021-02-20 04:40

    Realistically you need a setTimeout method in order to prevent redundant ajax calls being fired.

    clearTimeout(timer);
    
    if($("#txt1").val().length >= 2){
        timer = setTimeout(function(){
            get_data($("#txt1").val());
        }, 400);
    }else{
        get_default();
    }
    

    This should eradicate your problem.

提交回复
热议问题