0
我想加密密碼並通過Ajax調用帖子將其存儲在Mongo LAB上。 我收到以下錯誤: 我搜索了錯誤,但沒有得到它是什麼意思,它是指向循環。 錯誤:無法通過ajax調用發送Crypto JS加密數據
TypeError: Converting circular structure to JSON
at Object.stringify (native)
at n.$scope.signup (file:///C:/Users/naval.joshi/Desktop/eWallet/Assignment/Assignment/register.js:26:32)
at fn (eval at <anonymous> (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js:212:409), <anonymous>:4:209)
at f (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js:253:485)
at n.$eval (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js:133:221)
at n.$apply (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js:133:451)
at HTMLButtonElement.<anonymous> (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js:254:36)
at HTMLButtonElement.Hf.c (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js:35:217)
代碼:
var reg = angular.module('register', ['ngRoute']);
reg.controller('regCntrl', function($scope,$http) {
$scope.signup = function() {
$scope.encryptedData = CryptoJS.AES.encrypt($scope.password, "123");
alert($scope.encryptedData);
//alert("naval");
var inventory = {
name: $scope.name ,
email: $scope.email,
password: $scope.encryptedData,
phoneno:$scope.phoneno
};
$.ajax({
url: "https://api.mongolab.com/api/1/databases/geolocation/collections/boom?apiKey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
type: "POST",
data: JSON.stringify(inventory),
contentType: "application/json; charset=utf-8"
}).done(function(msg) {
console.log(msg);
});
};
// populate the code to fill mongo DB
});