我想在「郵件ID」字段中發送空值,因爲電子郵件ID不是表單中的必填字段。如何在ajax方法的數據中傳遞null作爲變量的值
var app = angular.module('MyApp', [])
app.controller('MyController', function($scope, $http, $window) {
$scope.ButtonClick = function() {
var post = $http({
method: "POST",
url: "url",
dataType: 'json',
data: {
name: $scope.Name,
mailID: $scope.MailID,
},
headers: {
"Content-Type": "application/json"
}
});
post.success(function(data, status) {
$window.alert(data.d);
});
post.error(function(data, status) {
$window.alert(data.Message);
});
}
});
使用這個'數據:{ \t名稱:$ scope.Name, \t mailID:($ scope.MailID)? $ scope.MailID:null }' –
顯示錯誤 - 「無法將null轉換爲值類型」 –
哪條線發生錯誤 –