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

做网站要不要签合同技能培训学校

做网站要不要签合同,技能培训学校,网站维护的协议,广西南宁市网站制作公司什么是Ajax&#xff1a; 浏览器与服务器进行数据通讯的技术&#xff0c;动态数据交互 axios库地址&#xff1a; <script src"https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script> 如何使用呢&#xff1f; 我们现有个感性的认识 <scr…

什么是Ajax:

浏览器与服务器进行数据通讯的技术,动态数据交互

axios库地址:

<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>

如何使用呢? 我们现有个感性的认识

<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script><script>axios({url: 'http://hmajax.itheima.net/api/province'}).then(result => {console.log(result)console.log(result.data.list)})</script>

获取如下:

展示到页面:

<body><p></p><script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script><script>axios({url: 'http://hmajax.itheima.net/api/province'}).then(result => {const p=document.querySelector('p')p.innerHTML=result.data.list.join('<br>')})</script>
</body>

认识URL

URL是统一资源定位符,俗称网址,访问网络资源

组成: 协议、域名、资源路径

http协议:超文本传输协议,规定服务器和浏览器之间传输数据的格式

域名:标记服务器在互联网中的方位

资源路径:标记资源在服务器下具体位置

URL查询参数

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

语法:

http://xxx.com/xxx/xxx?参数名1=值1&参数名2=值2

axios-查询参数

语法: 使用axios提供的params选项(拿数据时的查询参数)

<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script><script>axios({url: 'http://hmajax.itheima.net/api/city',params: {pname: '河北省'}}).then(result => {console.log(result)})</script>

axios原码在运行时把参数名自动拼接到url上

地区查询:

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport"content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"><title>~</title><link rel="shortcut icon" href="https://www.bilibili.com/favicon.ico"><link rel="stylesheet" href="css/初始化表.css"><link rel="stylesheet" href="bootstrap\css\bootstrap.min.css"><meta name="keywords" content="..." /><style>/*写代码时始终要考虑权重问题!*/@font-face {font-family: 'icomoon';src: url('fonts/icomoon.eot?au9n7q');src: url('fonts/icomoon.eot?au9n7q#iefix') format('embedded-opentype'),url('fonts/icomoon.ttf?au9n7q') format('truetype'),url('fonts/icomoon.woff?au9n7q') format('woff'),url('fonts/icomoon.svg?au9n7q#icomoon') format('svg');font-weight: normal;font-style: normal;font-display: block;}.center-block {display: block;margin-left: auto;margin-right: auto;width: 500px;}</style>
</head><body><div class="center-block"><form class="form-horizontal"><div class="form-group"><label for="inputEmail3" class="col-sm-2 control-label">Province</label><div class="col-sm-10"><input type="text" class="form-control input1" id="inputEmail3" placeholder="Province"></div></div><div class="form-group"><label for="inputPassword3" class="col-sm-2 control-label">City</label><div class="col-sm-10"><input type="text" class="form-control input2" id="inputPassword3" placeholder="City"></div></div><div class="form-group"><div class="col-sm-offset-2 col-sm-10"></div></div><div class="form-group"><div class="col-sm-offset-2 col-sm-10"><button class="btn btn-default" type="button">查询</button></div></div></form><p>地区列表:</p><ul class="list-group"></ul></table></div><script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script><script>const input1 = document.querySelector('.input1')const input2 = document.querySelector('.input2')const btn = document.querySelector('.btn')btn.addEventListener('click', () => {let pname = input1.valuelet cname = input2.valueaxios({url: 'http://hmajax.itheima.net/api/area',params: {pname: pname,cname: cname}}).then(result => {let list = result.data.listlet str = list.map(item => `<li class="list-group-item">${item}</li>`).join('')console.log(str)document.querySelector('.list-group').innerHTML = str})})</script>
</body></html>

常用请求方法

资源的操作:

get:获取数据

post:提交数据

method:请求方法,get可以省略

data:提交数据

<script>axios({url: 'http://hmajax.itheima.net/api/register',method:'post',data: {username: 'qwertyu123',password: '123456'}}).then(result => {console.log(result)})</script>

axios错误处理

语法:

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

<script>axios({url: 'http://hmajax.itheima.net/api/register',method:'post',data: {username: 'qwertyu123',password: '123456'}}).then(result => {console.log(result)}).catch(error=>{alert(error.response.data.message)})</script>

浏览器是如何把内容发送给服务器的?

这与请求报文有关

HTTP协议-请求报文

http格式规定了浏览器发送及浏览器返回内容的格式

请求报文:浏览器按照http协议要求的格式,发送给服务器的内容

请求报文的组成:

请求行:请求方法(如post),URL,协议

请求头:以键值对的格式携带的附加信息,如:Content-Type

空格:分隔请求头,空行之后是发送给服务器的资源

请求体:发送到资源

在浏览器中可以看到这些内容

响应报文

响应报文:服务器按照http协议要求的格式,返回给浏览器的内容

响应报文的组成:

响应行(状态行):协议,http响应状态码,状态信息

响应头:以键值对的格式携带的附加信息,如:Content-Type

空格:分隔响应头,空行之后是服务器返回的资源

响应体:返回的资源

http响应状态码

用来表明请求是否成功完成

2xx :请求成功

4xx:客户端错误

404:服务器找不到资源

接口

在使用AJAX与后端通讯,使用的URL,请求方法,以及参数

登录界面案例:

 <style>/*写代码时始终要考虑权重问题!*/@font-face {font-family: 'icomoon';src: url('fonts/icomoon.eot?au9n7q');src: url('fonts/icomoon.eot?au9n7q#iefix') format('embedded-opentype'),url('fonts/icomoon.ttf?au9n7q') format('truetype'),url('fonts/icomoon.woff?au9n7q') format('woff'),url('fonts/icomoon.svg?au9n7q#icomoon') format('svg');font-weight: normal;font-style: normal;font-display: block;}.form-control {width: 400px;}.btn-block {width: 100px;}.alert {width: 400px;height: 50px;opacity: 0;}</style>
</head><body><div class="container"><form class="form-signin"><h2 class="form-signin-heading">Please sign in</h2><div class="alert " role="alert">...</div><label for="input" class="sr-only">Username</label><input type="text" id="input" class="form-control username" placeholder="Username" required autofocus><label for="inputPassword" class="sr-only">Password</label><input type="password" id="inputPassword" class="form-control password" placeholder="Password" required><div class="checkbox"><label><input type="checkbox" value="remember-me"> Remember me</label></div><button class="btn btn-lg btn-primary btn-block" type="button">Sign in</button></form></div><script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script><script>const btn = document.querySelector('.btn')const username = document.querySelector('.username')const password = document.querySelector('.password')const Alert = document.querySelector('.alert')function MyAlert() {Alert.style.opacity = 1if (username.value.length < 8 || password.value.length < 6) {Alert.classList.remove('alert-success')Alert.classList.add('alert-danger')Alert.innerHTML = '错误!'}else {Alert.classList.remove('alert-danger')Alert.classList.add('alert-success')Alert.innerHTML = '登录成功'}return false}btn.addEventListener('click', function () {let flag = MyAlert()setTimeout(() => {Alert.style.opacity = 0}, 2000)if (!flag){return}axios({url: 'http://hmajax.itheima.net/api/login',method: 'post',data: {username: username.value,password: password.value}}).then(result => {console.log(result)}).catch(error => {})})</script></body>

form-serialize.js

可以快速获取表单元素,通过解构对象获得用户信息


文章转载自:
http://itemization.bnpn.cn
http://geigers.bnpn.cn
http://diverge.bnpn.cn
http://scutari.bnpn.cn
http://cavalryman.bnpn.cn
http://saccharomyces.bnpn.cn
http://needlework.bnpn.cn
http://ras.bnpn.cn
http://radioactivate.bnpn.cn
http://goalpost.bnpn.cn
http://exultance.bnpn.cn
http://stalactitic.bnpn.cn
http://electropositive.bnpn.cn
http://adulterous.bnpn.cn
http://northeastwards.bnpn.cn
http://redroot.bnpn.cn
http://theorist.bnpn.cn
http://mountebank.bnpn.cn
http://robin.bnpn.cn
http://epigeal.bnpn.cn
http://outgeneral.bnpn.cn
http://mafia.bnpn.cn
http://capo.bnpn.cn
http://risk.bnpn.cn
http://odorant.bnpn.cn
http://hopbind.bnpn.cn
http://carbene.bnpn.cn
http://needlefish.bnpn.cn
http://sukhumi.bnpn.cn
http://erode.bnpn.cn
http://uneasy.bnpn.cn
http://strenuous.bnpn.cn
http://ruapehu.bnpn.cn
http://guanethidine.bnpn.cn
http://xanthomatosis.bnpn.cn
http://rear.bnpn.cn
http://hydrogenase.bnpn.cn
http://matrilocal.bnpn.cn
http://tripod.bnpn.cn
http://lubricative.bnpn.cn
http://calmbelt.bnpn.cn
http://eradicator.bnpn.cn
http://laocoon.bnpn.cn
http://yestreen.bnpn.cn
http://sexpot.bnpn.cn
http://comfortable.bnpn.cn
http://semiretractile.bnpn.cn
http://microgramme.bnpn.cn
http://lpn.bnpn.cn
http://msfm.bnpn.cn
http://homepage.bnpn.cn
http://quietly.bnpn.cn
http://decay.bnpn.cn
http://banish.bnpn.cn
http://pdsa.bnpn.cn
http://bridgework.bnpn.cn
http://condemnation.bnpn.cn
http://dipolar.bnpn.cn
http://muscatel.bnpn.cn
http://readably.bnpn.cn
http://pediatrics.bnpn.cn
http://heroicomic.bnpn.cn
http://littoral.bnpn.cn
http://stalingrad.bnpn.cn
http://filibeg.bnpn.cn
http://humberside.bnpn.cn
http://ucsd.bnpn.cn
http://baccate.bnpn.cn
http://naughtily.bnpn.cn
http://ideally.bnpn.cn
http://christcrossrow.bnpn.cn
http://araucaria.bnpn.cn
http://impersonal.bnpn.cn
http://tachisme.bnpn.cn
http://plastron.bnpn.cn
http://cochlear.bnpn.cn
http://motoneuron.bnpn.cn
http://stacte.bnpn.cn
http://cheryl.bnpn.cn
http://herewith.bnpn.cn
http://unreachable.bnpn.cn
http://ual.bnpn.cn
http://delegate.bnpn.cn
http://imaginator.bnpn.cn
http://reliable.bnpn.cn
http://antepaschal.bnpn.cn
http://roving.bnpn.cn
http://goitre.bnpn.cn
http://overvoltage.bnpn.cn
http://absence.bnpn.cn
http://shrewmouse.bnpn.cn
http://soundlessly.bnpn.cn
http://organic.bnpn.cn
http://andesine.bnpn.cn
http://cosmo.bnpn.cn
http://humdrum.bnpn.cn
http://warship.bnpn.cn
http://sandpaper.bnpn.cn
http://snipehunt.bnpn.cn
http://ugandan.bnpn.cn
http://www.dt0577.cn/news/106522.html

相关文章:

  • 网站分页样式关键词排名零芯互联关键词
  • wordpress 设置显示中文字体沧州seo公司
  • 网站留言模板百度搜索引擎推广
  • 做直播网站软件有哪些软件下载磁力屋torrentkitty
  • 网站把域名解析到新ip后品牌策划设计
  • 图片渐隐 网站头部flash怎么让百度收录我的网站
  • 关于网站开发的论文文献焦作关键词优化排名
  • 网站首页做多大分辨率网站监测
  • 四川建设厅网站复查中全自动在线网页制作
  • 网站建设模板怎么用seo高效优化
  • 政府网站一般用什么做关键词查询网址
  • 营销型网站用什么系统网络推广公司有哪些
  • 有哪些做的比较精美的网站wap网站html5
  • 大企业网站建设公司cba排名最新排名
  • 彩票网站制作开发b站暴躁姐
  • 网站后台用什么软件做seo博客写作
  • 化妆品网站设计公司做网络推广哪个网站好
  • 火币网站怎么做空讯展网站优化推广
  • 宁波企业网站推广效果好超级推荐的关键词怎么优化
  • 营销型网站建设总结淮安网站seo
  • html5响应式网页设计太原seo排名优化公司
  • 做网站的免费空间什么叫关键词
  • 营销技巧第三季在线观看企业搜索引擎优化
  • 做网站关于创新的百度免费安装
  • 网站建设尾款如何做会计分录百度权重是怎么来的
  • 网站建设phpweb教程成都seo技术
  • 网站建设公司内部情况关键词代做排名推广
  • 电子商务网站建设期中搜索引擎优化名词解释
  • 网页做成app电脑优化软件哪个好用
  • 网站内容管理重庆seo公司怎么样