我有以下代码。从Chrome开发工具中点击发布按钮后,所有内容都是200 OK和302,但本地数据存储区中没有显示任何内容。
"推荐"模型
class Recommendation(ndb.Model):
comment = ndb.StringProperty()
从python webapp2发布方法
def post(self):
r = json.loads(self.request.body)
new_comment = Recommendation(comment=r['comment'])
new_comment.put()
/exp.html
<form ng-submit="addComment()" method="post" id="frmComment">
<textarea ng-model="formFields.comment" id="comment" name="comment" class="form-control status-box comment" rows="2"></textarea>
</form>
<div class="button-group pull-right">
<button form ="frmComment"class="btn btn-primary pst sameline" type="submit">Post</button>
</div>
&#13;
有角度的http帖子
$scope.formFields = {
comment : ""
}
$scope.comments = [];
$scope.addComment = function() {
var form_comment = $scope.formFields.comment
var payload = {
comment: form_comment
}
$http({
method: 'POST',
url: '/exp.html',
data: payload
}).then(function(response) {
$scope.comments.push(payload);
console.log(payload)
}, function(response) {
});