首页 > 其他分享 >Js-Ajax

Js-Ajax

时间:2022-10-17 21:36:57浏览次数:48  
标签:function url res Js Ajax password data id

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

标签:function,url,res,Js,Ajax,password,data,id
From: https://www.cnblogs.com/fengpeng123/p/16800759.html

相关文章

  • python爬虫从0到1 -ajax的get请求进阶
    前面说到获得了第一页的数据。而我们要获得后面的数据时,它们的url地址并不一样。详见下图:>第一页网址https://movie.douban.com/j/search_subjects?type=movie&tag=%E7%A7%......
  • 通过Js来设置页面样式
    介绍我们可以在编辑HTML源码的时候将CSS样式写死到.css文件或者HTML元素的style属性中,但又时候可能会需要动态地来修改某个元素的样式。我这里介绍两种方式:修改HTML元素的s......
  • 移动端适配+flexible.js+rem适配
    !function(a,b){functionc(){varb=f.getBoundingClientRect().width;b/i>540&&(b=540*i);varc=b/10;f.style.fontSize=c+"px",k.rem=a.rem=c}vard,e=a.document,f=e.d......
  • 原生js document.getElementById("XXX").disabled="false";无效
    想要设置表单元素不能访问时,使用document.getElementById("XXX").disabled="true";但是想要取消disabled的时候,发现document.getElementById("XXX").disabled="false";无......
  • Spring boot JSP
        路径            静态资源图片读取     ......
  • JS节流与防抖
    概述说明:在前端页面中,有些事件可能会由于用户不必要的操作而频繁触发,这在无形之中就增加了服务器的IO并发量.为了解决这个问题,我们通常会通过防抖或节流的方式对这类......
  • 在node中import from引入的文件要跟.js后缀,但是webapck不用?
    //a.jsletb=333;export{b};//index.jsimport{b}from'./a'//终端nodeindex.js//终端提示Error[ERR_MODULE_NOT_FOUND]:Cannotfindmodule'E:\Thousan......
  • @vitejs/plugin-vue
      需要cmd命令下载,我指定的版本是1.0.0,这里需要的node版本的要>=12.0.0 而我的vue版本是3.04>npmi@vitejs/[email protected] 以下的@vitejs/plugin-vue的......
  • js 外部调用 嵌套函数
     在函外部直接调用函数的内部函数是不可以的,因为是向外查找的 所以不能直接内部函数  functionone(){functiontwo(){varb=30;......
  • Nodejs相关ORM框架分析
    概述写这篇blog的原因,想找个node的ORM框架用用,确很难找到一篇对比分析这些ORM框架的文章,唯一找到了一篇,居然是通过star数来论英雄,我觉着很难服众,于是就找几个看看。后来又......