How to make JQuery-AJAX request synchronous

前端 未结 7 1996
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-30 09:55

How do i make an ajax request synchronous?

I have a form which needs to be submitted. But it needs to be submitted only when the user enters the correct password.

7条回答
  •  眼角桃花
    2020-11-30 10:37

    The below is a working example. Add async:false.

    const response = $.ajax({
                        type:"POST",
                        dataType:"json",
                        async:false, 
                        url:"your-url",
                        data:{"data":"data"}                        
                    });                   
     console.log("response: ", response);
    

提交回复
热议问题