jquery-Ajax请求用例码

时间:2023-03-08 19:18:02
jquery-Ajax请求用例码

$.ajax({
                    type:"post",
                    url: 'domain’,
                    success:function(data){
                   console.log(data);
                    } ,
                    dataType: "json",
                    async:false
                });

警告:Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/.

问题是永远不建议用 async:false ---->设置为:

$.ajax({
                    type:"post",
                    url: 'domain’,
                    success:function(data){
                   console.log(data);
                    } ,
                    dataType: "json",
                    async:true
                });

修改异步后,解决;