Vorlonjs icon indicating copy to clipboard operation
Vorlonjs copied to clipboard

The plugin XHR not working.

Open aiaisl opened this issue 9 years ago • 11 comments

When I work with vorlon xhr plugin with angular, I got the error

angular.js:13708 TypeError: Cannot read property 'apply' of undefined at XMLHttpRequest.o.setRequestHeader (default:7) at angular.js:11815 at forEach (angular.js:335) at angular.js:11813 at sendReq (angular.js:11642) at serverRequest (angular.js:11352) at processQueue (angular.js:16170) at angular.js:16186 at Scope.$eval (angular.js:17444) at Scope.$digest (angular.js:17257)

I try do some request use jquery, the plugin still not working.

aiaisl avatar Jul 11 '16 10:07 aiaisl

Hello,

Sorry for the delay :) Can you give me a simple sample of code that reproduce the issue?

etiennemargraff avatar Jul 25 '16 05:07 etiennemargraff

Hello :-D Here it is. When I open xhr listen, The angular request will fail.

<!DOCTYPE html>
<html lang="en" ng-app="mpApp">
<head>
    <meta charset="UTF-8">
    <title>Angular</title>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>
    <script src="http://192.168.2.137:1337/vorlon.js"></script>
</head>
<body ng-controller="MyController">
    <a href="javascript:;" ng-click="ajax()">send ajax</a>
    <script>
        var mpApp = angular.module('mpApp', [])
            .controller('MyController', ['$http', '$scope', function ($http, $scope) {
                $scope.ajax = function () {
                    //is fail
                    $http.get("https://httpbin.org/get");

                    //is ok
                    var oReq = new XMLHttpRequest();
                    oReq.open("get", "https://httpbin.org/get", true);
                    oReq.send();
                };
            }]);
    </script>
</body>

</html>
</html>

aiaisl avatar Jul 25 '16 09:07 aiaisl

We're also getting this error on every Ajax call from our Angular web app.

TypeError: Cannot read property 'apply' of undefined at XMLHttpRequest.o.setRequestHeader (http://localhost:1337/vorlon.js/default:7:46395) at http://localhost:3000/collection/www/vendor-e82ef307d2.js:24942:17 at forEach (http://localhost:3000/collection/www/vendor-e82ef307d2.js:13705:20) at http://localhost:3000/collection/www/vendor-e82ef307d2.js:24940:7 at sendReq (http://localhost:3000/collection/www/vendor-e82ef307d2.js:24793:9) at serverRequest (http://localhost:3000/collection/www/vendor-e82ef307d2.js:24503:16) at processQueue (http://localhost:3000/collection/www/vendor-e82ef307d2.js:29127:28) at http://localhost:3000/collection/www/vendor-e82ef307d2.js:29143:27 at Scope.$eval (http://localhost:3000/collection/www/vendor-e82ef307d2.js:30395:28) at Scope.$digest (http://localhost:3000/collection/www/vendor-e82ef307d2.js:30211:31) at Scope.$apply (http://localhost:3000/collection/www/vendor-e82ef307d2.js:30503:24) at HTMLTableRowElement.<anonymous> (http://localhost:3000/collection/www/vendor-e82ef307d2.js:65426:13) at defaultHandlerWrapper (http://localhost:3000/collection/www/vendor-e82ef307d2.js:16787:11) at HTMLTableRowElement.eventHandler (http://localhost:3000/collection/www/vendor-e82ef307d2.js:16775:9) at HTMLTableRowElement.wrapped (http://localhost:3000/collection/www/vendor-e82ef307d2.js:75428:29) at triggerMouseEvent (http://localhost:3000/collection/www/vendor-e82ef307d2.js:2953:7) at tapClick (http://localhost:3000/collection/www/vendor-e82ef307d2.js:2942:3) at HTMLDocument.tapMouseUp (http://localhost:3000/collection/www/vendor-e82ef307d2.js:3018:5) at HTMLDocument.wrapped (http://localhost:3000/collection/www/vendor-e82ef307d2.js:75428:29)

gkorland avatar Aug 18 '16 19:08 gkorland

Hello, sorry for the delay, just getting back from vacations ;)

Can you tell me more about your env ? Are you on a mac ? Which browser? Where is vorlon.js hosted ?

Thanks

etiennemargraff avatar Aug 22 '16 09:08 etiennemargraff

I'm on Ubuntu +Chrome, hosted locally.

gkorland avatar Aug 22 '16 12:08 gkorland

Hi. Some details: Vorlon url: http://192.168.88.37:1337 (ubuntu) If you open an application at: http://localhost:8080 - error occurs in any browser. http://192.168.88.37:8080 - no error in most browsers, but in android browser v4.2.0010:

message: Cannot read property 'apply' of undefined
stack: TypeError: Cannot read property 'apply' of undefined 
at XMLHttpRequest.o.setRequestHeader (http://192.168.88.37:1337/vorlon.js/default:7:46539) 
at setRequestHeader (eval at <anonymous> (http://192.168.88.37:8080/app.js:792:2), <anonymous>:125:19) 
at Object.forEach (eval at <anonymous> (http://192.168.88.37:8080/app.js:618:2), <anonymous>:221:12) 
at dispatchXhrRequest (eval at <anonymous> (http://192.168.88.37:8080/app.js:792:2), <anonymous>:119:13) 
at xhrAdapter (eval at <anonymous> (http://192.168.88.37:8080/app.js:792:2), <anonymous>:12:10) 
at dispatchRequest (eval at <anonymous> (http://192.168.88.37:8080/app.js:906:2), <anonymous>:52:10)

Stas404 avatar Dec 12 '16 09:12 Stas404

I am not sure but my first guess would be that this is some kind of browser restriction (CORS maybe?)

danielsteiner avatar Dec 12 '16 12:12 danielsteiner

@danielsteiner yes, it looks like that's the case. Perhaps, if we'll use a local proxy (before dev-server and Vorlon-script), we can avoid this error (if we need the one domain for both).

Stas404 avatar Dec 12 '16 19:12 Stas404

Yep I am pretty sure there is a CORS error here... did you try that local proxy or any workaround?

etiennemargraff avatar Dec 12 '16 23:12 etiennemargraff

@Stas404 Any news on that ?

etiennemargraff avatar Jan 31 '17 23:01 etiennemargraff

Same issue here with angular app image

ph55 avatar Jul 23 '17 11:07 ph55