jquery syntax

If you don't know how to check the official documents

Address https://www.w3school.com.cn/jquery/jquery_ref_ajax.asp

jQuery $.get() method

The $.get() method requests data from the server via an HTTP GET request.

grammar:
$.get(URL,callback);

The required URL parameter specifies the URL you wish to request.

The optional callback parameter is the name of a function to execute after a successful request.

The following example uses the $.get() method to retrieve data from a file on the server:

example
$("button").click(function(){
    
    
  $.get("demo_test.asp",function(data,status){
    
    
    alert("Data: " + data + "\nStatus: " + status);
  });
});
jQuery $.post() method

The $.post() method requests data from the server via an HTTP POST request.

grammar:
$.post(URL,data,callback);

The required URL parameter specifies the URL you wish to request.

The optional data parameter specifies the data to send with the request.

The optional callback parameter is the name of a function to execute after a successful request.

The following example uses $.post() to send data along with the request:

example
$("button").click(function(){
    
    
  $.post("demo_test_post.asp",
  {
    
    
    name:"Donald Duck",
    city:"Duckburg"
  },
  function(data,status){
    
    
    alert("Data: " + data + "\nStatus: " + status);
  });
});
case analysis
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 }); // See below for what it means

Address https://blog.csdn.net/suny2020/article/details/120360789

Guess you like

Origin blog.csdn.net/Ruiqi8/article/details/128288518