小编Cha*_*anX的帖子

AngularJS Interceptor TypeError:无法读取未定义的属性"标题"

我在尝试实现AJAX Spinner加载代码时出于不明原因获取此错误.

我不明白应该在哪里定义标题.我做了,console.log(config)但我可以看到headers: accept: text/html那里的价值.

以下是我的代码:

/**
* Spinner Service
*/

//Spinner Constants
diary.constant('START_REQUEST','START_REQUEST');
diary.constant('END_REQUEST','END_REQUEST');

//Register the interceptor service
diary.factory('ajaxInterceptor', ['$injector','START_REQUEST', 'END_REQUEST', function ($injector, START_REQUEST, END_REQUEST) {
    var $http,
    $rootScope,
    myAjaxInterceptor = {
        request: function (config) {
            $http = $http || $injector.get('$http');
            if ($http.pendingRequests.length < 1) {
                console.log(config);
                $rootScope = $rootScope || $injector.get('$rootScope');
                $rootScope.$broadcast(START_REQUEST);
            }
        }
    };

    return myAjaxInterceptor;
}]);

diary.config(['$httpProvider', function ($httpProvider) {
    $httpProvider.interceptors.push('ajaxInterceptor');
}]);
Run Code Online (Sandbox Code Playgroud)

javascript interceptor angularjs

7
推荐指数
2
解决办法
9714
查看次数

AngularJS Unknown TypeError:无法读取Null属性'1'

下面是我遇到问题的代码:

//Main Codes for the Diary App

(function () {
//Create a new diary app
var diary = angular.module('diary', ['ngRoute']);

//Define a Router for the App
diary.config(function ($routeProvider) {
        $routeProvider.


            when('/', {
                templateUrl: 'partials/wall.php',
                controller: 'DiaryWallController'
            }).


            when('/images', {
                templateUrl: 'partials/images.html',
                controller: 'DiaryImagesController'
            }).


            when('/audio', {
                templateUrl: 'partials/audio.html',
                controller: 'DiaryAudioController'
            }).


            otherwise({
                redirectTo: '/'
            });
});

//Define Controllers
diary.controller('DiaryWallController', function($scope) {
    $scope.message = "Lets do this!! Wall of this site";
});

diary.controller('DiaryImagesController', function($scope) {
    $scope.message = "Lets do this!! Images …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs

6
推荐指数
1
解决办法
9176
查看次数

Laravel 5.1 AJAX - 即使我发送POST请求,也不允许返回405 GET方法

当我通过AJAX发送POST请求时,我的Laravel POST路由返回405 GET方法.但是问题是它可以localhost在Heroku中工作但不能工作production server.我的AJAX POST请求作为GET请求发送到路由.下面我附上了截图和我的AJAX代码.

$.ajax({
            url: url,
            type: 'POST',
            data: data,
            contentType: 'application/json',
            headers: {
                'X-CSRF-TOKEN': token
            }
        })
Run Code Online (Sandbox Code Playgroud)

我的路线配置为:

Route::post('/adminpanel/projects/delete/', 'AdminPanelController@deleteData');
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

php ajax jquery heroku laravel-5.1

5
推荐指数
1
解决办法
6766
查看次数

如何过滤此 PHP 数组对象中的唯一对象

我有一个从服务器端生成的对象数组,我想在 PHP 中过滤重复项...

\n\n

下面是生成的数组

\n\n
array:5 [\xe2\x96\xbc\n  0 => {#204 \xe2\x96\xbc\n    +"category_name": "Fashion"\n    +"category_id": "fashion"\n  }\n  1 => {#205 \xe2\x96\xbc\n    +"category_name": "Fashion"\n    +"category_id": "fashion"\n  }\n  2 => {#209 \xe2\x96\xbc\n    +"category_name": "Shirts"\n    +"category_id": "shirts"\n  }\n  3 => {#210 \xe2\x96\xbc\n    +"category_name": "Health"\n    +"category_id": "health"\n  }\n  4 => {#211 \xe2\x96\xbc\n    +"category_name": "Shirts"\n    +"category_id": "shirts"\n  }\n]\n
Run Code Online (Sandbox Code Playgroud)\n\n

这里数组 0 和 1、数组 2 和数组 4 具有相同的值,如何过滤并仅获取现有数组或新生成的数组中的重复项的单个值。

\n

php arrays filter

2
推荐指数
1
解决办法
7649
查看次数

标签 统计

angularjs ×2

javascript ×2

php ×2

ajax ×1

arrays ×1

filter ×1

heroku ×1

interceptor ×1

jquery ×1

laravel-5.1 ×1