不懂得查看官方文档就行了
地址 https://www.w3school.com.cn/jquery/jquery_ref_ajax.asp
jQuery $.get() 方法
$.get() 方法通过 HTTP GET 请求从服务器上请求数据。
语法:
$.get(URL,callback);
必需的 URL 参数规定您希望请求的 URL。
可选的 callback 参数是请求成功后所执行的函数名。
下面的例子使用 $.get() 方法从服务器上的一个文件中取回数据:
实例
$("button").click(function(){
$.get("demo_test.asp",function(data,status){
alert("Data: " + data + "\nStatus: " + status);
});
});
jQuery $.post() 方法
$.post() 方法通过 HTTP POST 请求从服务器上请求数据。
语法:
$.post(URL,data,callback);
必需的 URL 参数规定您希望请求的 URL。
可选的 data 参数规定连同请求发送的数据。
可选的 callback 参数是请求成功后所执行的函数名。
下面的例子使用 $.post() 连同请求一起发送数据:
实例
$("button").click(function(){
$.post("demo_test_post.asp",
{
name:"Donald Duck",
city:"Duckburg"
},
function(data,status){
alert("Data: " + data + "\nStatus: " + status);
});
});
案例分析
function countryData() {
ajax_post('url地址', {
请求参数 id:01}, function (res) {
//进行ajax请求 res成功的回调函数
if (res.errCode === ERR_OK) {
var nowDate = new Date()
$('.now_time').text('截止时间' + nowDate.getFullYear() + '-' + (nowDate.getMonth() + 1) + '-' + nowDate.getDate()) // 把text(内容) 赋值给class为now_time的元素上 也就是塞给他
// $(".pro_sign_num").html(res.data.dayRegCount)
$('.pro_act_now_num').html(res.data.dayActNumber) // 把html(返回内容)赋值给class为pro_act_now_num 的html元素上 塞给他为html形式内容
$('.pro_reg_vol').html(res.data.regCount)
$('.serve_org_num').html(res.data.deptCount)
$('.pro_act_num').html(res.data.actNumber)
$('.serve_time_num').html(res.data.creditduration)
$('.honor_time_num').html(res.data.hisduration)
$('.current_num').countUp({
'time': 2500
});
}
}, function (err) {
console.log(err)
})
}
$(‘.current_num’).countUp({
‘time’: 2500
}); // 什么意思 看下面
地址https://blog.csdn.net/suny2020/article/details/120360789