问题基本上在标题中列出。这个应用程序是使用Angular JS构建的。我有两个相同的按钮在这个HTML文件中的不同div中相互堆叠,它们都调用相同的函数但具有不同的参数,但是只有一个函数实际更新了数据库中的所需值。另一个似乎最初是这样做的,但是一旦页面重新加载就好像没有发生任何变化。我们正在使用mLab数据库,并且我已经确认第二个函数传递的类型参数与数据库中的字段匹配。
HTML:
<div class="row">
<button class="btn farmerBtnGreen farmerMethod col-lg-6 col-md-offset-3" ng-click="emailFarmerAndAdmin(farmer,'organic')" ng-hide="farmer.organic == 1 || farmer.organic == 2">Start Organic Process</button>
<button class="btn methodVerify col-lg-8 col-md-offset-2" ng-show="farmer.organic == 1" disabled>Processing Organic Verification</button>
<button class ="btn methodVerified col-md-6 col-xs-offset-3" ng-show="farmer.organic == 2" disabled>Verified Organic</button>
</div>
<div class='row'>
<button class="btn farmerBtnGreen farmerMethod col-lg-8 col-md-offset-2" ng-click="emailFarmerAndAdmin(farmer,'conservationist')" ng-hide="farmer.conservationist == 1 || farmer.conservationist == 2">Start Conservationist Process</button>
<button class="btn methodVerify col-lg-10 col-md-offset-1" ng-show="farmer.conservationist == 1" disabled>Processing Conservationist Verification</button>
<button class ="btn methodVerified col-md-offset-3 col-xs-6" ng-show="farmer.conservationist == 2" disabled>Verified Conservationist</button>
</div>
JS:
$scope.emailFarmerAndAdmin = function (farmer, type) {
$scope.farmer[type] = 1
$http({
url: '/api/startVerify/' + JSON.stringify(farmer) + '/' + type,
method: 'POST'
}).success(function (data) {console.log(type}).error(function (data) {
console.log("Error")
});
};