jQuery的请求方式

①get获取数据

get("url?id="+_id,function(data){
console.log(data);
});

②post方法

 post(url, JSON.stringify(formData), function (data) {
    }, function (error, textStatus, errorThrown) {});
 post(url, {id:_id,name:_name}, function (data) {
    }, function (error, textStatus, errorThrown) {});

③ajax方法

$.ajax({
url:url,
type: 'GET',
contentType: "application/json",
dataType: 'json',
data: {},
success: function () {
       window.location.href = "/index";
},
 error: function (error, textStatus, errorThrown) {
       var responseJson = jQuery.parseJSON(error.text);
       alert(responseJson.message);
}
});


猜你喜欢

转载自blog.csdn.net/qq_36135928/article/details/80223736
今日推荐