myapp1 = angular.module('myApp', []);
myapp1.controller('jgCtrl', function($scope,$http) {
$http({
method:'post',
url:'json.php',
data:{name:'test',age:20},
}).then(function successCallback(response) {
alert('添加成功');
}, function errorCallback(response) {
alert('添加失败');
});
$http.get('json.php',{
}).then(function(res){
$scope.items=res.data;
console.log(res);
},function(){
alert('fault');
});
});
代码如上,我的目的是向php发送一个请求,使它可以根据我发出的data返回我想要的数据。
单下面的httpget运行是没有问题,可以正常接收表单的,但是我该如何修改代码才能使得前端能向php发送字段呢
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
你能把控制台的错误提示贴出来吗,我觉得并不一定是你的两次请求导致的问题