当前位置:网站首页>How to solve cross domain problems
How to solve cross domain problems
2022-06-30 12:38:00 【YF-SOD】
jsonp
utilize html in script Scripts do not resolve across domains .
<!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">
<title>Document</title>
</head>
<body>
<script>
function getData(data) {
console.log(data)
}
</script>
<script src="http://localhost:8080"></script>
</body>
</html>Server code
const http = require('http')
const server = http.createServer((req, res) =>
let url = req.url
// Set up 'Access-Control-Allow-Origin': '*' To solve the cross domain
//res.writeHead(200, {
// 'content-type': 'application/json;charset=utf-8',
// 'Access-Control-Allow-Origin': '*'
//})
res.write('getData("hello")')
res.end()
})
server.listen(8080,()=>{
console.log('localhost:8080')
})This will print hello character string , Note the usual get and post The data returned from the request server is ‘getData("hello")' String , Only stay script In order to be js Code execution .
Set request header Access-Control-Allow-Origin:*
For example, the notes in the above figure .
边栏推荐
- RDS MySQL数据迁移PolarDB MySQL费用可以转过去吗?
- SuperMap iDesktop 常见倾斜数据处理全流程解析
- Getting started with the go language is simple: go handles XML files
- Vision based robot grasping: from object localization, object pose estimation to parallel gripper grasping estimation
- 解决numpy.core._exceptions.UFuncTypeError: ufunc ‘add‘ did not contain a loop with signature matchin问题
- Redis configuration files and new data types
- 实现多方数据安全共享,解决普惠金融信息不对称难题
- Some commonly used hardware information of the server (constantly updated)
- Double dqn notes
- How difficult is data governance and data innovation?
猜你喜欢

实现多方数据安全共享,解决普惠金融信息不对称难题

Biological network analysis using deep learning

海思3559开发常识储备:相关名词全解
![[cloud native | kubernetes] in depth understanding of deployment (VIII)](/img/88/4eddb8e6535a12541867b027b109a1.png)
[cloud native | kubernetes] in depth understanding of deployment (VIII)
![[leetcode] 15. Sum of three numbers](/img/0c/4363d7737d90c170eb4519828990b9.png)
[leetcode] 15. Sum of three numbers

Conference Preview - Huawei 2012 lab global software technology summit - European session

Visual Studio配置Qt并通过NSIS实现项目打包

Hisilicon 3559 developing common sense reserves: a complete explanation of related terms

海思3559万能平台搭建:获取数据帧修改后编码

Map collection
随机推荐
The format of RTSP address of each manufacturer is as follows:
60 个神级 VS Code 插件!!
Browser plays RTSP video based on nodejs
Swagger2 automatically generates API documents
Introduction to sub source code updating: mid May: uniques NFT module and nomination pool
SQLSERVER 查询编码是 936 简体中文GBK,那我是写936 还是写GBK?
Map collection
qt msvc 安装及调试
A review of quantum neural networks 2022 for generating learning tasks
Use of polarplot function in MATLAB
解决numpy.core._exceptions.UFuncTypeError: ufunc ‘add‘ did not contain a loop with signature matchin问题
立创 EDA #学习笔记10# | 常用连接器元器件识别 和 无源蜂鸣器驱动电路
解决服务器重装无法通过ssh连接的问题
JMeter之性能测试流程及性能测试关注点
How to use the plug-in mechanism to gracefully encapsulate your request hook
Charles打断点修改请求数据&响应数据
When building the second website with pagoda, the website always reports an error: no input file specified
Efficient elliptic curve point addition and multiplication in scrypt
A new journey of the smart court, paperless office, escorting the green trial of the smart court
Map集合