angular.js - Why does angularjs report a 400 error when submitting data?
迷茫
迷茫 2017-05-15 17:11:38
0
3
580

Submit datagram 400badrequest
The front-end code is as follows:
<p ng-controller="faultInsCtrl">

<h1>xxx</h1>
<label class="label">线路号:</label>
<select class="select" ng-model="data.line_id">
    <option value=""></option>
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
    <option value="6">6</option>
    <option value="8">8</option>
    <option value="9">9</option>
</select>
<br><br>
<label class="label">列车号:</label>
<input type="text" class="inputtext" ng-model="data.train_id">
<br><br>
<label class="lable">巡检所在站台:</label>
<input type="text" class="inputtext" ng-model="data.station">

js code:
$scope.data = {

    line_id:$scope.line_id,
    train_id:$scope.train_id,
    station:$scope.station
};

$http({

            url: 'http://yiwuyahei.com/api/v1/issues',
            method: 'post',
            headers: {'Authorization': 'Bearer ' + data.access_token},
            data: $scope.data,
        })
            .success(function (data, status, headers, config) 
                alert(123);
            })
            .error(function (data, status, headers, config) {
                //
            })
    })
    请大神指导哪里有问题?
    
迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(3)
为情所困

400 means parameter error. Check whether the request parameters sent match the requirements of the background interface code~

仅有的幸福

400 is a parameter error. You should communicate with the backend first

phpcn_u1582

It may be a content-type problem. Ask about the format of the data transmitted in the background. Try adding contentType: "application/json".

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template