Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从angularjs向laravel发送put请求_Angularjs_Rest_Laravel - Fatal编程技术网

从angularjs向laravel发送put请求

从angularjs向laravel发送put请求,angularjs,rest,laravel,Angularjs,Rest,Laravel,我正试图发送angularjs的put请求。我的应用程序接收器正在运行laravel 当我尝试发送请求时,收到以下错误消息: TypeError: Cannot set property '_method' of undefined at $http.transformRequest (http://localhost:8000/js/controller-university.js:91:28) at transformData (http://localhost:8000/j


我正试图发送angularjs的put请求。我的应用程序接收器正在运行laravel
当我尝试发送请求时,收到以下错误消息:

TypeError: Cannot set property '_method' of undefined
    at $http.transformRequest (http://localhost:8000/js/controller-university.js:91:28)
    at transformData (http://localhost:8000/js/libs/angular/angular.js:7433:12)
    at serverRequest (http://localhost:8000/js/libs/angular/angular.js:8071:23)
    at wrappedCallback (http://localhost:8000/js/libs/angular/angular.js:11572:81)
    at wrappedCallback (http://localhost:8000/js/libs/angular/angular.js:11572:81)
    at http://localhost:8000/js/libs/angular/angular.js:11658:26
    at Scope.$eval (http://localhost:8000/js/libs/angular/angular.js:12701:28)
    at Scope.$digest (http://localhost:8000/js/libs/angular/angular.js:12513:31)
    at Scope.$apply (http://localhost:8000/js/libs/angular/angular.js:12805:24)
    at HTMLFormElement.<anonymous> (http://localhost:8000/js/libs/angular/angular.js:19139:23) 
怎么了?

这里是正确的代码:

       update: function(data){
          return $http({
            method: 'PUT', 
            url: '/api/university/'+data.id, 
            data: $.param(data), 
            headers: { 'Content-Type' : 'application/x-www-form-urlencoded' }
          });
        },   
它对我很有用。

$.param()函数的作用是什么,您可以发送指向它文档的链接吗?我正在尝试使用这个,但它对我不起作用。
       update: function(data){
          return $http({
            method: 'PUT', 
            url: '/api/university/'+data.id, 
            data: $.param(data), 
            headers: { 'Content-Type' : 'application/x-www-form-urlencoded' }
          });
        },   
var request = {
    method: 'put',
    url: '/admin/banners/'+$scope.editid,
    data: fields,
    headers: {
        'Content-Type':'application/json'
    }
};