The plugin XHR not working.
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.
Hello,
Sorry for the delay :) Can you give me a simple sample of code that reproduce the issue?
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>
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)
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
I'm on Ubuntu +Chrome, hosted locally.
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)
I am not sure but my first guess would be that this is some kind of browser restriction (CORS maybe?)
@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).
Yep I am pretty sure there is a CORS error here... did you try that local proxy or any workaround?
@Stas404 Any news on that ?
Same issue here with angular app
