1.get方式
$.ajax({
url: 'http://ckt.ck9696.com/api/domesticStatistical/getCount',
type: 'get',
dataType: 'json',
contentType: 'application/json',
async: false, //同步ajax,默认为true,异步ajax
success: function (data) {
data1 = parseInt(data.data.todayTotalWeight)
},
error: function (xhr, errorMessage, e) { //请求异常执行此方法,参数名不建议修改,可
以不写这个函数
alert(errorMessage);
}
});
2.post方式
$.ajax({
url: '',
data: {
name: 'zhangsan',
pwd: '123'
},
type: 'post',
dataType: 'text',
success: function (res) {
$('#post1').html(res)
},
error: function (xhr, errorMessage, e) {
alert(e)
}
})