Ajax

一、基于JS的Ajax的实现

step1: var xmlhttp=XMLHttprequest()

step2: xmlhttp.open("")  #连接server端

step3: xmlhttp.send("name=alex")  #请求体的内容 if GET请求: send(null)

step4: 监听xmlhttp(if ==4:{var xmlhttp.responetext})

二、JSON与JSONP

三、基于Jquery的Ajax的实现

1、ajax $.get()

2、ajax $.post()

3、$.ajax

$.ajax两种表现形式

1)$.ajax({name:"alex",})

2)$.ajax("url",{其他参数})

4、$.ajax参数

$.ajax({

url:"index.html",

type:"POST",            //"GET"

data:{a:1,b:2},           //data里面时json对象

processData:false,    //告诉游览器不对发送的数据进程编码处理 (二进制数据、DOM数据)

contentType:text

})

原文地址:https://www.cnblogs.com/xibuhaohao/p/10484986.html