跨域

it2024-04-20  7

非同源请求,结尾跨域 同源指相同的协议、主机、端口、

不允许跨域读取操作

 

jsonp 只支持get请求

1 <link rel="stylesheet" href="http://localhost:3000/"> 这种方法是以允许的 2 router.get('/', function(req, res, next) { 3 console.log('收到了客户端的请求:', req.url); 4 // res.end('hello, itlike!'); 5 res.end('body{background-color: red;}'); 6 }); 1 router.get('/', function(req, res, next) { 2 console.log('收到了客户端的请求:', req.url); 3 var data = JSON.stringify({ 4 'status': 200, 5 'result': { 6 'name': '撩课学院', 7 'site': 'itlike.com' 8 } 9 }); 10 res.end('getData(' + data + ')'); 11 }); 12 13 14 页面 15 <script> 16 function getData(data) { 17 console.log(data); 18 } 19 20 </script> 21 <script src="http://localhost:3000/"></script>

转载于:https://www.cnblogs.com/zhangzhengyang/p/11223560.html

最新回复(0)