Skip to content

Latest commit

 

History

History
70 lines (53 loc) · 1 KB

ajax写法.md

File metadata and controls

70 lines (53 loc) · 1 KB

ajax写法

1.方式一
1.方式一
$.ajax({
	url:'',
    type:'',
    dataType:'',
    data:'',
    headers:'',
    success:function(msg){
        
    },
    error: function(msg){
        
    }
});
2: 方式二 get请求简写
$.get(url,function(msg){
    
});
3: 方式三 post请求简写
$.post(url,data,function(msg){
    
});
4: 方式四 提交上传文件
$(this).ajaxSubmit({
    url:'',
    type:'',
    dataType:'',
    data:'',
    headers:'',
    success:function(msg){   
    },
    error: function(msg){
        
    }
})
return false;  //阻止主动第二次提交
5, 前端有多个值需要获取
$('#form-house-info').submit(function () {
    var a = $(this).serialize() //获取多个值
    $.post('/house/newhouseinfo/', a ,function (data) {

        if (data.code == '200'){
            location.href = '/house/myhouse/'
        }
    });
    return false;
});