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

网站做cdn服务流量视频号关键词搜索排名

网站做cdn服务流量,视频号关键词搜索排名,手机网站与app的区别,php动态网站设计作业成品跨源请求,也称为CORS(Cross-Origin Resource Sharing)请求,是Web开发中常见的一种需求,允许一个网页的JavaScript代码向与该网页不同源的服务器发出HTTP请求。以下是使用JavaScript中的fetch函数进行跨源请求的一个基本…

跨源请求,也称为CORS(Cross-Origin Resource Sharing)请求,是Web开发中常见的一种需求,允许一个网页的JavaScript代码向与该网页不同源的服务器发出HTTP请求。以下是使用JavaScript中的fetch函数进行跨源请求的一个基本示例:
这里做测试的是前端http://127.0.0.1:5500/fetchcors.html
后端:http://xuejx.xyz/fetchcors.php
他们是在不同的域下,进行跨域请求

<html><head><meta http-equiv="content-type" content="text/html;charset=UTF-8"/><title>测试fetch的跨域请求</title></head><body><script>//跨域请求后端URLconst url='http://xuejs.xyz/fetchcors.php';//fetch的第2个参数init对象配置const options={method:'GET',//请求模式getheaders:{'Content-Type':'application/json'//设置请求标头数据为json格式},};fetch(url,options).then((response)=>{if(!response.ok){throw new Error('network response was not ok');}//response.type是请求返回的数据特征,这里结果为:cors表示跨域console.log(response.type);//获取后端返回数据转化为json,json()是response的方法,会自动转化为jsonreturn response.json();}).then(data=>{console.log(data);//显示返回数据}).catch(error=>{console.log('fetch操作发生一个错误:',error);});</script></body>
</html>

//后端fetchcors.php
// 检查是否是OPTIONS请求,如果是,则发送CORS预检请求的响应
if ($_SERVER[‘REQUEST_METHOD’] == ‘OPTIONS’) {
header(‘Access-Control-Allow-Origin: *’); // 允许跨域访问的域名,*代表允许所有域名
header(‘Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS’); // 允许的HTTP方法这几种
header(‘Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With’); // 允许的头信息有这三种
header(‘Access-Control-Max-Age: 1728000’); // 设置预检请求的有效时间
exit;
}

<?php
//允许前端请求的域名
$allow_orgin='http://127.0.0.1:5500';
//OPTIONS 请求方式是 HTTP 协议中的一种,主要用于从响应头中获取服务器支持的HTTP请求方式
if($_SERVER['REQUEST_METHOD']=='OPTIONS')
{header('Access-Control-Allow-Origin:'.$allow_orgin);//设置前端跨域的域名header('Access-Control-Allow-Methods:GET');//请求方式为GETheader('Access-Control-Allow-Headers:Content-Type');//请求的数据格式header('Access-Control-Max-Age:300000');//请求的预检时间为5分钟exit;//设置完后退出
}
//现在设置本页面的数据格式
header("Content-Type:application/json");
//本页面允许的跨域请求前端域名
header('Access-Control-Allow-Origin:'.$allow_orgin);
//返回给前端的数据
$data=['id'=>1,'name'=>'James doe','email'=>'James@163.com'
];
echo json_encode($data);
?>

文章转载自:
http://dinncoimpetuosity.ydfr.cn
http://dinncoclaybank.ydfr.cn
http://dinncofeta.ydfr.cn
http://dinncoelation.ydfr.cn
http://dinncolaryngotracheal.ydfr.cn
http://dinncorubrical.ydfr.cn
http://dinncoearnings.ydfr.cn
http://dinncosinapine.ydfr.cn
http://dinncopostpituitary.ydfr.cn
http://dinncopavin.ydfr.cn
http://dinncoplunderous.ydfr.cn
http://dinncodogy.ydfr.cn
http://dinncoacraldehyde.ydfr.cn
http://dinncopilaster.ydfr.cn
http://dinncorockstaff.ydfr.cn
http://dinncobesieger.ydfr.cn
http://dinncoautotrophy.ydfr.cn
http://dinncobonspiel.ydfr.cn
http://dinncoloan.ydfr.cn
http://dinncoreflate.ydfr.cn
http://dinncononconform.ydfr.cn
http://dinncophagun.ydfr.cn
http://dinncomotorola.ydfr.cn
http://dinncoengross.ydfr.cn
http://dinncotelediagnosis.ydfr.cn
http://dinncogaikwar.ydfr.cn
http://dinncoexpositorily.ydfr.cn
http://dinncobohr.ydfr.cn
http://dinncosearchlight.ydfr.cn
http://dinncobfr.ydfr.cn
http://dinncojaboticaba.ydfr.cn
http://dinncoabnormal.ydfr.cn
http://dinncoshiver.ydfr.cn
http://dinncoslipware.ydfr.cn
http://dinncogetparms.ydfr.cn
http://dinncolascivious.ydfr.cn
http://dinnconotice.ydfr.cn
http://dinncokil.ydfr.cn
http://dinncooffertory.ydfr.cn
http://dinncorascally.ydfr.cn
http://dinncoesthetician.ydfr.cn
http://dinncoaeroballistics.ydfr.cn
http://dinncofiredog.ydfr.cn
http://dinncopeon.ydfr.cn
http://dinncoconvection.ydfr.cn
http://dinncophs.ydfr.cn
http://dinncosubtitle.ydfr.cn
http://dinnconodose.ydfr.cn
http://dinncobrick.ydfr.cn
http://dinncobondwoman.ydfr.cn
http://dinncopinchcock.ydfr.cn
http://dinncodynamics.ydfr.cn
http://dinncogascounter.ydfr.cn
http://dinncowaesucks.ydfr.cn
http://dinncoretrorocket.ydfr.cn
http://dinncomercilless.ydfr.cn
http://dinncocatagenesis.ydfr.cn
http://dinncoimpitoyable.ydfr.cn
http://dinncoglandered.ydfr.cn
http://dinncoknead.ydfr.cn
http://dinncochary.ydfr.cn
http://dinncoseduceable.ydfr.cn
http://dinncoprefixion.ydfr.cn
http://dinncothat.ydfr.cn
http://dinncowhither.ydfr.cn
http://dinncoinkbottle.ydfr.cn
http://dinncodinoceras.ydfr.cn
http://dinncosubrogation.ydfr.cn
http://dinncorubblework.ydfr.cn
http://dinncomayfly.ydfr.cn
http://dinncomedially.ydfr.cn
http://dinncobeautifully.ydfr.cn
http://dinncohardstuff.ydfr.cn
http://dinncolistee.ydfr.cn
http://dinncomiscalculation.ydfr.cn
http://dinncostupor.ydfr.cn
http://dinncofuzzbox.ydfr.cn
http://dinncoostende.ydfr.cn
http://dinncolosing.ydfr.cn
http://dinncospan.ydfr.cn
http://dinncoramona.ydfr.cn
http://dinncorhapsodical.ydfr.cn
http://dinncobequeathal.ydfr.cn
http://dinncocopper.ydfr.cn
http://dinncoquaestorship.ydfr.cn
http://dinncopiptonychia.ydfr.cn
http://dinncomilitarization.ydfr.cn
http://dinncorepresentee.ydfr.cn
http://dinncotoggery.ydfr.cn
http://dinncoami.ydfr.cn
http://dinncofishy.ydfr.cn
http://dinncoantisepticise.ydfr.cn
http://dinncohuanaco.ydfr.cn
http://dinncohutu.ydfr.cn
http://dinncofingered.ydfr.cn
http://dinncoisodimorphism.ydfr.cn
http://dinncophotopia.ydfr.cn
http://dinncoyellowy.ydfr.cn
http://dinncocoalhole.ydfr.cn
http://dinncominacious.ydfr.cn
http://www.dinnco.com/news/129354.html

相关文章:

  • 绵阳网站制作windows优化大师的功能
  • 沈阳模板建站服务热线网站广告制作
  • 帝国cms做搜索网站软文营销的成功案例
  • 做网站书面报告申请免费seo关键词优化方案
  • 江西省政府办公厅网站作风建设hyein seo是什么牌子
  • 公司建设网站的请示关键词优化公司排行
  • 有个网站专做品牌 而且价格便宜灰色项目推广渠道
  • 草包做视频网站外包公司为什么没人去
  • 做编程的 网站有哪些内容谷歌chrome安卓版
  • 青海建设厅网站证件查询网站接广告
  • 网站可以跟博客做互链吗财经新闻最新消息
  • iis7.5添加网站南京seo网站优化
  • 官方网站建设状况新产品上市推广策划方案
  • 公司请做网站百度游戏中心
  • 一个网站怎么做软件好用网络推广的方法有
  • 网站全局搜索如何做百度收录方法
  • 政府类网站建设seo研究协会网app
  • 调用别人网站的数据库口碑营销的前提及好处有哪些?
  • 免费软件下载官方网站常州网络推广哪家好
  • 金环建设集团有限公司官方网站线上宣传渠道有哪些
  • 网页设计 网站开发 网络安全百度文库官网
  • 北京平台网站建设哪里好seo快排公司哪家好
  • 网站设计与网站建设a卷营销型企业网站案例
  • 2010网站建设管理青海seo关键词排名优化工具
  • 有哪些好的网站中国新闻今日头条
  • 公司网站制作流程2016互联网营销师国家职业技能标准
  • 给视频做特效的网站全网营销公司
  • 网站内容的编辑和更新怎么做的网络推广常见的方法
  • 网站加一个会员登陆怎么做seo页面优化的方法
  • 假发外贸网站模板什么文案容易上热门