简体   繁体   English

angularjs routeProvider在实时服务器上不起作用

[英]angularjs routeProvider not working on live server

I have just uploaded a project to a live server from my localhost, but I'm having a bit trouble with some links! 我刚刚从本地主机将项目上载到实时服务器,但是某些链接有点麻烦! In my routeProvider I have this: 在我的routeProvider中,我有:

$routeProvider.when('/projects/:project', {
  templateUrl: 'partials/projectPage.html',
  controller: 'ProjectPageCtrl'
})

But when I go to page that are in a link text mysite. 但是,当我转到链接文本mysite中的页面时。 com/projects/testing, the hole site crashes and I get this error in the console: com / projects / testing,漏洞站点崩溃,并且我在控制台中收到此错误:

SyntaxError: Unexpected token <
at eval (native)
at mysite. com/js/jquery-1.8.0.min.js:2:14066
at Function.p.extend.globalEval (mysite. com/js/jquery-1.8.0.min.js:2:14077)
at p.ajaxSetup.converters.text script (mysite. com/js/jquery-1.8.0.min.js:2:83767)
at cC (mysite. com/js/jquery-1.8.0.min.js:2:5858)
at y (mysite. com/js/jquery-1.8.0.min.js:2:79924)
at d (mysite. com/js/jquery-1.8.0.min.js:2:85578)
at Object.send (http://mysite. com/js/jquery-1.8.0.min.js:2:85705)
at Function.p.extend.ajax (mysite. com/js/jquery-1.8.0.min.js:2:82575)
at HTMLScriptElement.<anonymous> (mysite. com/js/jquery-1.8.0.min.js:2:68258) <div ng-view="" class="ng-scope"> angular.js:9503

But when I'm running it on my localhost everything is working fine. 但是,当我在本地主机上运行它时,一切正常。 So I have no idea what's wrong :( 所以我不知道怎么了:(

Hope that someone can help me with this :) 希望有人可以帮助我:)

This seems like backend error. 这似乎是后端错误。 If you're using REST API, make sure your JSON is valid. 如果您使用的是REST API,请确保您的JSON有效。 Similar errors are caused if you try to JSON.parse a HTML page: 如果尝试JSON.parse HTML页面,则会导致类似的错误:

在此处输入图片说明

Open the REST API url with your browser and see what's wrong. 使用浏览器打开REST API网址,然后查看有什么问题。 You can use the network tab to preview the response like this(assuming you're using Chrome, but most of the modern browsers can do this): 您可以使用“网络”标签来预览响应(假设您使用的是Chrome,但是大多数现代浏览器都可以这样做):

在此处输入图片说明

Okej I have found out the problem, first so was my base href wrong! Okej我发现了问题,首先我的基本href错误! And for the second one so I switch to jQuery 1.7.2 and now it's working just fine, So it's seams to be a bug in jQuery 1.8.0 第二个,所以我切换到jQuery 1.7.2,现在它可以正常工作了,所以它似乎是jQuery 1.8.0中的一个错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM