SSM-同步请求与异步请求

同步请求和异步请求
同步请求:阻塞
1、表单提交,是同步请求

........ 2、超级链接访问,是同步请求
<a href=”register?user_name=fsd&user_pwd=123>点击提交</a>

3、直接访问URL地址,是同步请求

http://localhost:8080/register?user_name=fsd&user_pwd=123

异步请求:非阻塞
Ajax
//通过ajax方式传递后台

$.ajax({
    
    
    url:"/register",  //提交后台URI地址
    type:"get", //请求方式:get、post
    data:{
    
    user_name:user_name,user_pwd:user_pwd}, //提交参数:js对象,json字符串,序列化
    dataType:"json", //响应类型
    success:function(response){
    
     //成功后回调函数
        if(response.code == 200){
    
    
            window.location.href = "/login.html";
        }
        if(response.code == 500){
    
    
           alert(response.message);
        }
    }
})

猜你喜欢

转载自blog.csdn.net/dgssd/article/details/112969036