search

Home  >  Q&A  >  body text

angular.js - Why does angularjs report a 400 error when submitting data?

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) {
                //
            })
    })
    请大神指导哪里有问题?
    
迷茫迷茫2757 days ago588

reply all(3)I'll reply

  • 为情所困

    为情所困2017-05-15 17:13:38

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

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-05-15 17:13:38

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

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-05-15 17:13:38

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

    reply
    0
  • Cancelreply