簡體   English   中英

AngularJS中的Register方法不起作用

[英]Register method in AngularJS is not working

當我發送帖子請求時,我已經在http://pselleruserregistration.azurewebsites.net/api/Account/Register中部署了webApi,但它不起作用,但是在提琴手中卻起作用。 下面是代碼

scotchApp.controller('signupController', function ($scope, $http) {

    $scope.signUp = function () {

        return $http({

            url: 

           'http://pselleruserregistration.azurewebsites.net/api/Account/Register',

            dataType: 'json',

            method: 'POST',

            data: {

                "Email": "rrrk@gmail.com",

                "Password": "Samplestring@2",

                "ConfirmPassword": "Samplestring@2"

            },

            headers: {

                "Content-Type": "application/json"

            }

        })

    }

});

我嘗試了您的代碼,發現的錯誤與跨域請求有關。

在該域授予您許可之前,您無法對該域執行任何ajax請求。

您需要在服務器端添加這些標頭。

Access-Control-Allow-Headers: Content-Type
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Allow-Origin: *

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM