我为自己创建了一个投资组合网站。我使用angular.js显示我的关于我的#39;文字内容和我的投资组合图像和内容。即使在重新加载网站之后,它仍可在我家中的每台计算机上完美运行。截至上周,我一直在收到有关某些计算机无法正常工作的报告。我很难搞清楚这是托管问题还是我的问题,因为报告它不工作的人一周前没有这个问题,我从那时起就没有更新过。
链接为http://www.davidsandersdesigns.com/。我觉得自己很麻烦,因为一切都在我的所有浏览器和我的机器上工作正常,即使我的缓存被清空后也是如此。我有时会收到401错误。有时候我没有。请帮忙!
这是我的json文件。
{
"aboutMeContent": {
"paragraph1": "My name is David A. Sanders. I am a front-end web developer and graphic designer. I am fresh out of school and currently looking for a job where I may apply my skills, be challenged, and learn new things. I love design, creativity, web animation, ones/zeros, learning, french-pressed coffee, and my beautiful family…..did I mention my family? They are the reason I decided to pursue web development after all.",
"paragraph2": "Aside from wrestling midgets (my kids), changing diapers, and day dreaming…..My top technical skills are HTML5, CSS3, JavaScript, Velocity.js, jQuery, and web animation. My top design skills are Photoshop, Illustrator, and just simple pencil and paper."
},
"portTileContent": [{
"name": "Charlottes 3rd Birthday",
"type": "Graphic Design/Print",
"skills": "Adobe Illustrator",
"notes": "This is a birthday card I created for my beautiful daughter. Picture courtesy of Photographer Carly Miller.",
"link":"",
"image": "images/viewerImages/CharBdayCard3yr_viewerImage.png"
}, {
"name": "domSpace Animation Project",
"type": "Web Design/Animation",
"skills": "HTML5, CSS3, Velocity.js, Object-Oriented Javascript, Illustrator",
"notes": "An Animation project I created to practice my programming skills.",
"link": "<strong>Link:</strong> Visit the link <a href='http://www.davidsandersdesigns.com/domspace/' target=_blank>here<\/a>",
"image": "images/viewerImages/domSpaceImage_viewerImage.png"
}, {
"name": "Something Stiched Something Sewn",
"type": "Graphic Design/Print",
"skills": "Adobe Illustrator",
"notes": "A business card I created for Donna Pierce/Seamstress.",
"link": "<strong>Link:</strong> Visit her facebook <a href='https://www.facebook.com/SomethingStichedSomethingSewn/?fref=ts' target=_blank>here<\/a>",
"image": "images/viewerImages/somethingStiched_viewerImage.png"
}, {
"name": "davidsandersdesigns.com build 2000",
"type": "Web Design/My Portfolio Site",
"skills": "HTML5, SASS, Bootstrap3, Angular.js, Velocity.js, Illustrator, Photoshop",
"notes": "My Personal site to showcase my work.",
"link": "<strong>Link:</strong> You are already here!",
"image": "images/viewerImages/dsdesignsBuild2000_viewerImage.png"
}]
}
这是我的控制器文件。
app.controller('myCtrl', function($scope, $http) {
$http.get("http://www.davidsandersdesigns.com/angular.js/data.json").success(function(data) {
$scope.aboutMe = data.aboutMeContent;
$scope.portTileSpecs = data.portTileContent;
});
});
这是我的应用文件
var app = angular.module('myApp', []);
angular.module('myApp')
.filter('to_trusted', ['$sce', function($sce){
return function(text) {
return $sce.trustAsHtml(text);
};
}]);
答案 0 :(得分:1)
我能够通过在Chrome中打开没有www
的网站来复制问题,并且出现了CORS错误。
这是因为在发出ajax请求时,www.site.com
和site.com
实际上被浏览器视为跨域。
更改:
$http.get("http://www.davidsandersdesigns.com/angular.js/data.json")
要
$http.get("/angular.js/data.json")
OR:
将页面加载时,将服务器配置为始终重定向到www
或不www
。
人们已经习惯了不再需要www
在网址中的网站