我正在学习jasmine,现在我正在尝试使用github API测试$.getJSON以获取github用户名。这是我正在运行的代码:
index.html:
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Jasmine Tests</title>
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.6.2/jasmine.css">
</head>
<body>
<script
src="http://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.6.2/jasmine.js">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.6.2/jasmine-
html.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.6.2/boot.js">
</script>
<script type="text/javascript" src="test.js"></script>
</body>
</html>test.js:
function getUserInfo(username){
return $.getJSON('https://api.github.com/users/' + username);
//remember that all jquery ajax methods return a promise!
}
describe("#getUserInfo", function(){
it("returns the correct name for the user", function(done){
getUserInfo('elie').then(function(data){
expect(data.name).toBe('Elie Schoppik');
done(); //invoke to make sure the test does not timeout
});
});
});我在cloud9上运行,得到以下错误:
混合内容:“https://preview.c9users.io/pvanny1124/web-dev-bootcamp-1/Jasmine/index.html?_c9_id=livepreview12&_c9_host=https://ide.c9.io”处的页面是通过HTTPS加载的,但请求了不安全的脚本“http://code.jquery.com/jquery-3.3.1.min.js”。此请求已被阻止;必须通过HTTPS提供内容。
我能做什么?提前谢谢你!!
发布于 2018-02-24 11:57:35
通过HTTPS加载所有引用。将此行更改为使用HTTPS。
<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>https://stackoverflow.com/questions/48958614
复制相似问题