当前位置:网站首页>1-21 jsonp interface
1-21 jsonp interface
2022-06-30 21:29:00 【Endless pie】
review JSONP The concept and characteristics of
Concept : Browser pass
characteristic :
- JSONP It doesn't belong to the real Ajax request , Because it's not used XMLHttpRequest This object .
- JSONP Support only GET request , I won't support it POST、PUT、DELETE Equal request .
establish JSONP Interface precautions
If... Has been configured in the project CORS Cross-domain resource sharing , In order to prevent conflict , Must be configured CORS The middleware previously declared JSONP The interface of . otherwise JSONP The interface will be processed as open CORS The interface of .
Realization JSONP Interface steps
- Get the name of the callback function sent by the client
- Get through JSONP Data sent to the client as
- According to the data from the first two parts , Splice a string of function calls .
- Concatenate the string obtained in the previous step , Response to
// Must be configured cors Previous configuration JSONP
app.get('/api/jsonp',(req,res)=>{
// Get the name of the function
const funcname = req.query.callback
const data = {
name:'zs',
age:22
}
const scriptStr = `${funcname}(${JSON.stringify(data)})`
res.send(scriptStr)
})
边栏推荐
- 1-11 创建线上文件服务
- How to run jenkins build, in multiple servers with ssh-key
- ICLR'22 Spotlight | 怎样度量神经网络权重中的信息量?
- Zaah Sultan looks at the old driver
- [grade evaluator] how to register a grade evaluator? How many passes?
- 1-17 express中间件
- 雷达数据处理技术
- ceshi deces
- twelve thousand three hundred and forty-five
- Fletter nested hell? No, constraintlayout to save!
猜你喜欢

Radar data processing technology

Five years after graduation, I wondered if I would still be so anxious if I hadn't taken the test

《ClickHouse原理解析与应用实践》读书笔记(3)

文本生成模型退化怎麼辦?SimCTG 告訴你答案

科研中遇到迷茫困惑如何向前一步?如何在科研中发挥女性优势?

Why have the intelligent investment advisory products collectively taken off the shelves of banks become "chicken ribs"?
Understand what MySQL index push down (ICP) is in one article

ArcGIS构建发布简单路网Network数据服务及Rest调用测试
Testing media cache

本地浏览器打开远程服务器上的Jupyter Notebook/Lab以及常见问题&设置
随机推荐
DM8:生成DM AWR报告
银行集体下架的智能投顾产品,为何成了“鸡肋”?
Sqlserver string type converted to decimal or integer type
Fletter nested hell? No, constraintlayout to save!
Analysis and proposal on the "sour Fox" vulnerability attack weapon platform of the US National Security Agency
clickhouse原生監控項,系統錶描述
ca i啊几次哦啊句iu家哦
利用日志服务器输出各种apache的日志的TOPN
Personal developed penetration testing tool Satania
开源实习经验分享:openEuler软件包加固测试
一文读懂什么是MySQL索引下推(ICP)
侧睡哈哈哈哈
What does grade evaluation mean? What is included in the workflow?
Can flinksql two Kafka streams join?
测试媒资缓存问题
Double solid histogram / double y-axis
USBCAN分析仪的配套CAN和CANFD综合测试软件LKMaster软件解决工程师CAN总线测试难题
ArcGIS构建发布简单路网Network数据服务及Rest调用测试
3Ds Max 精模obj模型导入ArcGIS Pro (二)要点补充
你我他是谁