一、学习内容
ajax的简单回顾:
前后端数据交互都是字符串 - json
readystate
ajax状态码 0 1 2 3 4
1.安装了nodejs运行环境
2.安装nodemon的插件
npm install nodemon -g
3.在app.js同级目录下打开黑窗口
nodemon app.js
4.到浏览器中输入 127.0.0.1:3000
5.运行你的html文件的话 127.0.0.1:3000/01我的ajax文件.html
===================================
get和post请求数据的区别。
传统数据方式 key=val&key2=val2;
get直接在地址栏拼接数据;
请求头的配置。
post需要把数据方法send中。
-----------------------------------
请求头的配置。
传递json格式(必须使用post方式)
传统表单传递数据
// http://www.baidu.com?uname=zs&gender=女&age=18
post才需要 setRequestHeader 设置请求头信息
// xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')传统表单post参数传递需要写到send中
|