2019.03.24 Ajax

也还是会用到jquery中的Ajax请i求 

所以第一还是引入jQuery包   可以去网上搜腾讯网静态资源库

然后引入包    Ajax还是异步处理  处理堵塞问题  import time 就可以了

概要

Ajax 即“Asynchronous Javascript And XML”(异步 JavaScript 和 XML),是指一种创建交互式网页应用的网页开发技术。

局部刷新技术。

应用场景: 在页面比较复杂情况下,只需要更新局部内容。

语法

  1. GET请求


var data = {'uname':'zhangsan'}

  //发送ajax请求
  $.get('/student/getinfo/',data,function(result){

      alert(result.hello)
  })
   
   
  1. POST请求


var csrf = $('input[name="csrfmiddlewaretoken"]').val();
var data = {'uname':'zhangsan','csrfmiddlewaretoken':csrf}
$.post('/student/getinfo/',data,function(result){
              alert(result.hello)
          })
  1. 自定义AJAX请求

  2. $.ajax({
    url:'/student/getinfo/',
    type:'get',
    data:'uname=lisi&pwd=123',
    async:true,
    success:function (result) {
    var test = result.hello

    $('#hid').html(test)
    }

    })

猜你喜欢

转载自www.cnblogs.com/Py-king/p/10590744.html
今日推荐