岁月如歌,,,|

千夜ん

园龄:6年粉丝:0关注:0

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");

本文作者:千夜ん

本文链接:https://www.cnblogs.com/fengpeng123/p/16800759.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   千夜ん  阅读(43)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起