Js-Ajax

jQuery Ajax

1 ajax

$.ajax({
        type: 'POST',//请求方式 GET/POST
        url: "/api/jsonws/cch-portlet.scorestatisticshelper/list-exam-score",//url地址
    	async: false,
        data: { "id": id, "password": password, "role_id": role_id },//传给后端的参数
        dataType: 'json',//返回数据的类型 text/json/html
        success: function (res) {//回调函数  res:后台返回的数据
            getPlanName(res.datas);
        }
    });

2 POST

post:
$.post() 方法使用 HTTP POST 请求从服务器加载数据。
语法 $.post(URL,data,function(data,status,xhr),dataType)

1.第一种写法

var url = "/api/jsonws/cch-portlet.scorestatisticshelper/list-exam-score"
var data = {
      id:id,
      password,password
}

$.post(url,data,function(res){
     getPlanName(res.datas);
},"json");

2.第二种写法

var url = "/api/jsonws/cch-portlet.scorestatisticshelper/list-exam-score"
var data = {
      id:id,
      password,password,
}

$.post(url,data).then(function(res){
     getPlanName(res.datas);
});

3 GET

get:
$.get() 方法使用 HTTP GET 请求从服务器加载数据。
语法:$.get(url,data,function(data,status,xhr),dataType)

var url = "/api/jsonws/cch-portlet.scorestatisticshelper/list-exam-score"
var data = {
      id:id,
      password,password
}

$.get(url,data,function(res){
     getPlanName(res.datas);
},"json");		
posted @ 2022-10-17 21:19  千夜ん  阅读(47)  评论(0)    收藏  举报