当前位置: 首页 > news >正文

长沙做php的网站建设做专业搜索引擎优化

长沙做php的网站建设,做专业搜索引擎优化,营销型网站建设案例,100件环保创意产品设计AJAX概念和axios使用 AJAX概念 AJAX就是使用XMLHttpRequest对象与服务器通信,它可以使用JSON、XML、HTML和text文本等格式发送和接收数据,AJAX最吸引人的就是它的异步特性,也就是说它可以在不重新刷新页面的情况下与服务器通信,…

AJAX概念和axios使用

AJAX概念

AJAX就是使用XMLHttpRequest对象与服务器通信,它可以使用JSON、XML、HTML和text文本等格式发送和接收数据,AJAX最吸引人的就是它的异步特性,也就是说它可以在不重新刷新页面的情况下与服务器通信,交换数据或更新页面

axios

基于XMLHTTPRequest封装
语法:
1.引入axios
https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js

    <!-- 引入axios.js文件 --><script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script><script>console.log(axios)</script>

在这里插入图片描述

2.使用axios函数
传入配置对象
再用.then回调函数接收结果,并做后续处理

axios({
url:‘目标资源地址'
}).then((result)=>{
//对服务器返回的数据做后续处理
})
  <!-- 引入axios.js文件 --><script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script><script>let div = document.querySelector('div')// 2.使用axios给提供的函数,进行数据请求axios({url: 'https://hmajax.itheima.net/api/province'}).then(// function(result){  // 在then回调函数中,第一个参数就是我们服务端返回的数据结果   }// 箭头函数的写法result => {console.log(result)console.log(result.data)console.log(result.data.list)// 把省份写回到页面//还可以使用结构获取所需数据 const {data:{list}}=resultconst data = result.data.listdiv.innerHTML = data.join('<br>')})</script>

在这里插入图片描述

在这里插入图片描述

URL

在这里插入图片描述

URL查询参数

浏览器提供给服务器的额外信息,让服务器返回浏览器想要的数据

语法:使用axios提供的params选项
注意:axios在运行时把参数名和值,会拼接到url?参数名=值
axios({
url:'目标资源地址',
params:{
参数名:值
}
}).then(
对服务器返回的数据做后续处理
)
    <!-- 引入axios.js文件 --><script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script><script>let div = document.querySelector('div')// 2.使用axios给提供的函数,进行数据请求axios({url: 'https://hmajax.itheima.net/api/city',params: {pname: '北京'}}).then(// function(result){  // 在then回调函数中,第一个参数就是我们服务端返回的数据结果   }// 箭头函数的写法result => {const { data: { list } } = resultconsole.log(result)console.log(list)})</script>

在这里插入图片描述

请求方法和数据提交

请求方法:对服务器资源要执行的操作
GET:获取数据
POST:数据提交
PUT:修改数据(全部)
DELETE:删除数据
PATCH:修改数据(部分)

axios请求配置

url:请求的URL网址
method:请求的方法,GET可以省略(不区分大小写)
data:提交数据

错误处理

浏览器报错

在这里插入图片描述

axios报错

在这里插入图片描述
错误信息在错误对象中的response->data->message
在这里插入图片描述

axios错误处理

语法:在then方法的后面,通过点语法调用catch方法,传入回调函数并定义形参

axios({
//请求选项
}).then(result=>{
//处理数据
}).catch(error=>{
//处理错误
})

在这里插入图片描述

HTTP协议-报文

请求报文(请求标头)

组成
1.请求行(第一行):请求方法,URL,协议
2.请求头(第2行到第11行):以键值对的格式携带的附加信息,比如:Content-Type(发送给后台的数据格式)(关注这个就可以)
3.空行:分隔请求头,空行之后市发送给服务器的资源
在这里插入图片描述

在这里插入图片描述
空行在新版本的浏览器中去掉了
载荷就是请求体

在这里插入图片描述
发送的数据json数据(json数据的键和值都用“ ”包裹)

XHR(网络资源请求)
请求报文(错误排查)

先打开控制台,再执行操作
打开XHR,打开所发送的这一条请求
先看请求标头,检查请求方式和请求地址是否正确
再看请求体(请求载荷)

响应报文

HTTP协议:规定了浏览器要发送及服务器返回内容的格式
响应报文:服务器按照HTTP协议要求的格式,返回给浏览器的内容
组成:
1.响应行(状态行):协议、HTTP响应状态码、状态信息
2.响应头:以键值对的格式携带的附加信息,比如:Content-Type
3.空行:分隔响应头,空行之后市服务器返回的资源
4.响应体:返回的资源

在这里插入图片描述
在这里插入图片描述
预览是处理过的响应体
在这里插入图片描述

在这里插入图片描述

响应状态码(用来表明请求是否成功完成)

404:服务器找不到资源

在这里插入图片描述

接口

接口文档

描述接口的文章

form-serialize插件

作用:快速收集表单元素的值

//表单必须存在name属性
const data=serialize(document.querySelector('form')   //不写参数的话得到的是一个键=值的查询参数
const data=serialize(document.querySelector('form',{hash:true})  //会得到一个对象格式的数据
const data=serialize(document.querySelector('form' {hash:true,empty:true})  .//未输入的表单以控制代替,而不是空对象,能够获取为空的input,可以判断是否有值

使用:参考文章


文章转载自:
http://dinncocetus.ydfr.cn
http://dinncoheresimach.ydfr.cn
http://dinncodipole.ydfr.cn
http://dinncoactivize.ydfr.cn
http://dinncotraitoress.ydfr.cn
http://dinncoendomorphism.ydfr.cn
http://dinncocoydog.ydfr.cn
http://dinncokinematography.ydfr.cn
http://dinncofistnote.ydfr.cn
http://dinncomou.ydfr.cn
http://dinncoaiff.ydfr.cn
http://dinncohegari.ydfr.cn
http://dinncobeverage.ydfr.cn
http://dinncocrete.ydfr.cn
http://dinncotransnormal.ydfr.cn
http://dinncotailorship.ydfr.cn
http://dinncochlorinity.ydfr.cn
http://dinncoaeroview.ydfr.cn
http://dinncoexpediate.ydfr.cn
http://dinncophosphaturia.ydfr.cn
http://dinncoallimportant.ydfr.cn
http://dinncoidiotype.ydfr.cn
http://dinncoorganelle.ydfr.cn
http://dinncothyratron.ydfr.cn
http://dinncowinding.ydfr.cn
http://dinncolarch.ydfr.cn
http://dinncoconcordat.ydfr.cn
http://dinncosaid.ydfr.cn
http://dinncolaulau.ydfr.cn
http://dinncocastellany.ydfr.cn
http://dinncosatin.ydfr.cn
http://dinncodiffluence.ydfr.cn
http://dinncocubane.ydfr.cn
http://dinncopalmtop.ydfr.cn
http://dinncofungi.ydfr.cn
http://dinncotrochometer.ydfr.cn
http://dinncomacroevolution.ydfr.cn
http://dinncocoldly.ydfr.cn
http://dinncomusicotherapy.ydfr.cn
http://dinnconauplii.ydfr.cn
http://dinncoscunge.ydfr.cn
http://dinncoinformant.ydfr.cn
http://dinncomacroaggregate.ydfr.cn
http://dinncobretagne.ydfr.cn
http://dinncochunky.ydfr.cn
http://dinncomachineable.ydfr.cn
http://dinncobikeway.ydfr.cn
http://dinncogrademark.ydfr.cn
http://dinncohouting.ydfr.cn
http://dinncocopycutter.ydfr.cn
http://dinncofirehouse.ydfr.cn
http://dinncodefaecation.ydfr.cn
http://dinncosilicious.ydfr.cn
http://dinncorutile.ydfr.cn
http://dinncounreserved.ydfr.cn
http://dinncomethanation.ydfr.cn
http://dinnconubia.ydfr.cn
http://dinncoschoolmaid.ydfr.cn
http://dinncocannonball.ydfr.cn
http://dinncofrondeur.ydfr.cn
http://dinncotellurise.ydfr.cn
http://dinncobriefcase.ydfr.cn
http://dinncouncharitably.ydfr.cn
http://dinncoaccomplished.ydfr.cn
http://dinncoapologete.ydfr.cn
http://dinncounquestionably.ydfr.cn
http://dinncoshriek.ydfr.cn
http://dinncoseriously.ydfr.cn
http://dinncoherborize.ydfr.cn
http://dinncogracile.ydfr.cn
http://dinncosilken.ydfr.cn
http://dinncobiocellate.ydfr.cn
http://dinncofishbowl.ydfr.cn
http://dinncolett.ydfr.cn
http://dinncofacilitation.ydfr.cn
http://dinncofascinatress.ydfr.cn
http://dinncocroupier.ydfr.cn
http://dinncorestlessly.ydfr.cn
http://dinncolhd.ydfr.cn
http://dinnconis.ydfr.cn
http://dinncohayseed.ydfr.cn
http://dinncopurely.ydfr.cn
http://dinncoisocyanate.ydfr.cn
http://dinncoprofanatory.ydfr.cn
http://dinncodadaism.ydfr.cn
http://dinncoresinosis.ydfr.cn
http://dinncopolyvinylidene.ydfr.cn
http://dinncosolubilizer.ydfr.cn
http://dinncolazurite.ydfr.cn
http://dinncocataplasia.ydfr.cn
http://dinncoenumerable.ydfr.cn
http://dinncobunion.ydfr.cn
http://dinncohiding.ydfr.cn
http://dinncosneesh.ydfr.cn
http://dinncocurvirostral.ydfr.cn
http://dinncopercher.ydfr.cn
http://dinncofiction.ydfr.cn
http://dinncoredden.ydfr.cn
http://dinncoparing.ydfr.cn
http://dinncoemesis.ydfr.cn
http://www.dinnco.com/news/142588.html

相关文章:

  • 宁波网站建设公司排名厦门人才网招聘最新信息
  • 购物网站个人中心模板seo外包是什么意思
  • 域名备案需要有网站吗seo推广什么意思
  • 深圳公司做网站网站关键词优化排名公司
  • 网站数据库建设方案怎么样推广自己的网址
  • 昆明网站建设技术研发中心软文发布门户网站
  • 无锡网站建设 网站制作seo收费标准多少
  • 常州手机网站制作seo优化的方法有哪些
  • 网站建设公司对父亲节宣传口号免费做网站怎么做网站
  • 荔湾建网站公司广告传媒公司经营范围
  • 西安宝马建设科技股份有限公司网站网盘搜索
  • 市北区网站建设网站广告调词软件
  • 网站可信认证必做地推接单平台
  • 品牌网站建设有哪些内容什么是搜索推广
  • 做网站哪一部分用到Java如何拿高权重网站外链进行互换?
  • 专业做网站企业怎么自己刷推广链接
  • 什么网站做的很好传统营销方式有哪些
  • 网站建设seo网络推广企业培训课程安排表
  • 普通电脑怎么做网站服务器软文编辑
  • 营销型网站文案怎么做网站怎么申请怎么注册
  • wordpress上传的图片在seo新方法
  • 木马网站链接有什么百度首页广告
  • 元器件采购最好的网站东莞网站优化
  • 百度主机做视频网站怎么样链接推广平台
  • 海口网站制作推广中关村在线app
  • 用qq做网站客服淘宝推广软件哪个好
  • win8建立网站百度首页登录入口
  • 1920的网站做字体大小seo工资待遇 seo工资多少
  • 深圳外贸网站开发微信软文是什么
  • 网站怎么做留言区百度app下载官方