基于JS的ajax的实现,JSON和JSONP,基于JQuery的ajax的实现
1.基于JS的ajax的实现
step1: var xmlhttp = XMLHttprequest() #实例化一个对象
step2: xmlhttp.open("") #url地址
step3: xmlhttp.send("name=alex") #请求体的内容 if GET请求 :send(null)
step4: 监听:xmlhttp(if ==4:{var context=xmlHttp.responsetext})
GET:ajax具体实现(JS方式):
Title
POST:请求注意事项
POST请求必须设置ContentType请求头的值为:application/x-www-form-urlencoded。
表单的enctype默认值就是为application/x-www-form-urlencoded,因为默认值就是这个,
当设置了