当前位置:网站首页>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)
})
边栏推荐
- The 16th Heilongjiang Provincial Collegiate Programming Contest
- It is urgent for enterprises to protect API security
- ArcGIS construction and release of simple road network data service and rest call test
- 科研中遇到迷茫困惑如何向前一步?如何在科研中发挥女性优势?
- 【无标题】第一次参加csdn活动
- k个一组反转链表
- Clickhouse Native Monitoring item, System table Description
- 【等级测评师】等级测评师怎么报名?多少分及格?
- Zaah Sultan looks at the old driver
- 1-20 预检请求
猜你喜欢

Clickhouse Native Monitoring item, System table Description

3Ds Max 精模obj模型导入ArcGIS Pro (二)要点补充

Spatiotemporal data mining: an overview

文本识别-SVTR论文解读

Clickhouse native monitoring item, system table description

介绍一款|用于多组学整合和网络可视化分析的在线平台

Reading notes of Clickhouse principle analysis and Application Practice (2)

Phoenix architecture: an architect's perspective
Testing media cache

ICML2022 | 序列决策的效用理论
随机推荐
开发属于自己的包
Open source internship experience sharing: openeuler software package reinforcement test
代码改变一小步,思维跨越一大步
申请Vector 总线协议彩图壁纸挂画,非常棒哦!
go搭建服务器基础
Use the log server to output the topn of various Apache logs
元宇宙可能成为互联网发展的新方向
介绍一款|用于多组学整合和网络可视化分析的在线平台
《ClickHouse原理解析与应用实践》读书笔记(3)
侧睡哈哈哈哈
1-13 express监听GET和POST请求&处理请求
Oracle 数据库表结构 Excel 导出
ICLR'22 Spotlight | 怎样度量神经网络权重中的信息量?
To the Sultanate of Anderson
Text recognition svtr paper interpretation
Multi table operation - foreign key constraint
ArcGIS构建发布简单路网Network数据服务及Rest调用测试
1-19 利用CORS解决接口跨域问题
NCAT detailed introduction (Reprint)
Introduction of 3D Max fine model obj model into ArcGIS pro (II) key points supplement