2013-02-07 36 views
2

我正在使用的代码如下,在coffeescipt:

request_with_token = 
    get: 
    method: "JSONP", 
    params: 
     token: app["token"] 
    save: 
    method: "POST", 
    params: 
     token: app["token"] 

$rootScope.API = "http://0.0.0.0:5200/1.0" 

$scope.ajaxAccountUpdate = $resource($rootScope.API + "/account/update.json", 
    { callback: "JSON_CALLBACK" }, request_with_token) 

user = $scope.user 
$scope.ajaxAccountUpdate.save user, (resource) -> 
    $scope.show_message(resource) 

但在我的日志我有一个选项,而不是一个POST

[07/Feb/2013 16:50:48] "OPTIONS /1.0/account/update?callback=JSON_CALLBACK&token=mytoken HTTP/1.1" 200 - 

谢谢

+0

见http://stackoverflow.com/questions/14593130/angular-resource-dont-change-method/14593360#14593360 – dnc253

回答

2

可能是因为您正在向不同的网站提供HTML服务的请求,导致“跨源资源共享”CORS飞行前检查。这是一项安全功能:

欲了解更多信息:http://www.html5rocks.com/en/tutorials/cors/

+0

+1。确保您在浏览器中查看网站的网址与'$ rootScope.API'中的网址匹配。 –

相关问题