【发布时间】:2020-09-26 10:09:29
【问题描述】:
我正在尝试使用 JSONP 跨域加载数据表单。在脚本中传递的回调参数不会在控制台中打印任何数据。
我将从另一台服务器加载week-7.js,但我在本地尝试它不起作用。我无法更改服务器端部分的任何代码我无权更改它
我把这个<script> 放在 HTML 中
<button onclick="clickButton()">click me</button>
<script>
function renderTable(data){
console.log(data)
}
function clickButton() {
var s = document.createElement("script");
s.type = "text/javascript"
s.src = "week-7.js?callback=renderTable";
document.body.appendChild(s);
}
</script>
这是我的第 7 周.js
const data = {
"noWeek": 1,
"fstWeek": 1,
"week": 1,
"end": 1591459131848,
"profiles": {
"test1": {
"id": "test1",
"type": "3",
"name": "test test",
"picture": {
"uri": "/flag.png"
},
"country": "IN",
"ed": 1,
"gs": 100,
"ts": 13.0,
"in": 31,
"px": 34
}
},
"leaders": [
"test1"
]
}
有什么问题吗?有什么建议吗?
【问题讨论】:
标签: jsonp