当前位置:网站首页>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)
})
边栏推荐
- ca i啊几次哦啊句iu家哦11111
- 侧睡哈哈哈哈
- 激发新动能 多地发力数字经济
- Electronic scheme development - Intelligent rope skipping scheme
- Apply for vector bus protocol color picture wallpaper hanging picture, very good!
- Three techniques for reducing debugging time of embedded software
- Go build server Foundation
- 雷达数据处理技术
- 将el-table原样导出为excel表格
- 兴奋神经递质——谷氨酸与大脑健康
猜你喜欢
Adobe Photoshop (PS) - script development - remove file bloated script
3Ds Max 精模obj模型导入ArcGIS Pro (二)要点补充
介绍一款|用于多组学整合和网络可视化分析的在线平台
Understand what MySQL index push down (ICP) is in one article
asp. Net core JWT delivery
防范未授权访问攻击的十项安全措施
开源实习经验分享:openEuler软件包加固测试
网络营销之四大误解
jupyterbook 清空控制台输出
《ClickHouse原理解析与应用实践》读书笔记(3)
随机推荐
代码改变一小步,思维跨越一大步
Adobe Photoshop (PS) - script development - remove file bloated script
DM8:生成DM AWR报告
clickhouse原生监控项,系统表描述
jenkins下载插件下载不了,解决办法
Learning summary
Random talk about Clickhouse join
Internet of things botnet gafgyt family and backdoor vulnerability exploitation of Internet of things devices
Oprator-1 first acquaintance with oprator
Electronic scheme development - Intelligent rope skipping scheme
MySQL advanced 3
ca i啊几次哦啊句iu家哦
的撒啊苏丹看老司机
Ssh server configuration file parameter permitrootlogin introduction
Understand what MySQL index push down (ICP) is in one article
How to run jenkins build, in multiple servers with ssh-key
减少嵌入式软件调试时间的三个技巧
1-17 express中间件
文本生成模型退化怎麼辦?SimCTG 告訴你答案
物联网僵尸网络Gafgyt家族与物联网设备后门漏洞利用