body {
background: rgba(10, 10, 10, .8);
}
.wrapper {
margin: auto;
position: relative;
width: 100%;
}
.item-2 {
border: 2px solid blue;
box-sizing: border-box;
display: inline-block;
text-align: center;
width: 50%;
}
.demo {
background: yellow;
height: 5em;
margin: auto;
width: 5em;
}
我有这个代码和控制台返回一个错误,上面写着"成功不是功能"我该如何解决?
答案 0 :(得分:1)
使用then
代替success
。
.then(onSuccess)
function onSuccess(data){
}
我认为你应该这样做
HTML
<input ng-model="formData.yourName">
<input ng-model="formData.lstName">
<input ng-model="formData.password">
在js
function yourcontroller($scope){
var $scope.formData={};
$http({
method:'POST',
url:'insert.php',
data:$.param($scope.formData)
headers : { 'Content-Type': 'application/x-www-form-urlencoded' }
}) .then(onSuccess,onError)
function onSuccess(data){
//handle success
}
function onError(reason){
//handle error
}
}
答案 1 :(得分:0)
.success
,使用.then
。喜欢:
.then(function(data){
alert(data);// handle data
}, function(error) {
//handle error
});