xmlhttprequest

how to use xhr.overrideMimeType in Chrome / IE Edge?

徘徊边缘 提交于 2019-12-24 07:14:24
问题 I have an issue with sending a file (part of a request in form data format). The issue seems coming from the fact that only in Chrome for Linux the file (which is CVS file, with .csv extension and basically just text) is sent with mimetype (Content-type in request body) Content-Type: application/octet-stream So, I am trying to override the mimetype to match the same sent by Chrome on Linux which is text/csv . However the mimetype is apparently not overriden and still send as octet-stream . My

how to use xhr.overrideMimeType in Chrome / IE Edge?

我的梦境 提交于 2019-12-24 07:14:14
问题 I have an issue with sending a file (part of a request in form data format). The issue seems coming from the fact that only in Chrome for Linux the file (which is CVS file, with .csv extension and basically just text) is sent with mimetype (Content-type in request body) Content-Type: application/octet-stream So, I am trying to override the mimetype to match the same sent by Chrome on Linux which is text/csv . However the mimetype is apparently not overriden and still send as octet-stream . My

Chrome/WebKit XHR File Upload

陌路散爱 提交于 2019-12-24 06:53:19
问题 I have searched relentlessly but just can't figure this one out. Why will this XHR connection work perfectly fine in Firefox but breaks in Chrome? I'm using this in conjunction with AngularJS, by the way. $scope.upload = function(project, file) { var formData = new FormData(); //Not really sure why we have to use FormData(). Oh yeah, browsers suck. formData.append('', file.file); //The real file object is stored in this file container file.xhr = new XMLHttpRequest(); file.xhr.open('PUT', '

Chrome/WebKit XHR File Upload

限于喜欢 提交于 2019-12-24 06:53:17
问题 I have searched relentlessly but just can't figure this one out. Why will this XHR connection work perfectly fine in Firefox but breaks in Chrome? I'm using this in conjunction with AngularJS, by the way. $scope.upload = function(project, file) { var formData = new FormData(); //Not really sure why we have to use FormData(). Oh yeah, browsers suck. formData.append('', file.file); //The real file object is stored in this file container file.xhr = new XMLHttpRequest(); file.xhr.open('PUT', '

Get client IP in javascript/angularjs

孤街醉人 提交于 2019-12-24 06:45:31
问题 I'm trying to get client IP in my angular app. I'm using this code: $http.get("http://l2.io/ip.js").then(function(response) { $scope.ip = response.data; }); But it make Error: XMLHttpRequest cannot load http://l2.io/ip.js. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9001' is therefore not allowed access. How to add headers? 回答1: There is a service provider that provides CORS headers (Access-Control-Allow-Origin: *) for javascript

How to show the internal server errors to the user?

筅森魡賤 提交于 2019-12-24 06:03:19
问题 I am working in an API . I want to throw detailed error messages to the user. Now i am in a situation to decide what kind of error code should be sent or how to explain user if any error occurs in the application internally. For example if database connection fails , what kind of http status code i want to send to the user ? Can anyone help ? 回答1: An HTTP status code generally refers to the status of the HTTP request itself, not the status of the application handling the request. Therefore,

XHR cross-domain error on the same domain (localhost)

一曲冷凌霜 提交于 2019-12-24 04:33:24
问题 Explanation: I have a small web application running on apache server on a machine that uses javascript to do some XHR's. For a long time it worked with no problems, today all the XHR's stopped working but only on localhost, if you access it from outside it works perfectly. Problem: Using mozilla firefox, firebug warns: "Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://127.0.0.1:3581/datasnap/rest/TdssMloteamento/getLoteamento/true/ . This

iframe sends origin as null

こ雲淡風輕ζ 提交于 2019-12-24 03:34:27
问题 I have an iframe to which the content is injected from the third party library I am using. <iframe id="targetIframe"></iframe> The library is injecting a form which user needs to submit. Problem is that when the form is initialized they are doing some requests and header origin is send as a null which is causing a problem because their servers are not allowing null value. I tried to add sandbox attribute, even tried to fake the call but with origin but the iframe is secured with CORS. Is

Uncaught TypeError: Value is not of type AudioBuffer

我的未来我决定 提交于 2019-12-24 03:27:48
问题 I get this error when I try to run an XHR to load a sample. Uncaught TypeError: Value is not of type AudioBuffer. Everything seems to be right, but I'm not sure what the problem is. Kit.prototype.load = function(){ if(this.startedLoading) return; this.startedLoading = true; // var kick = "samples/M-808Sn2.wav"; var snare = "samples/M-808Sn2.wav"; // var hihat = "samples/M-808Sn2.wav"; // this.loadSample(0, kick, false); this.loadSample(1, snare, false); // this.loadSample(2, hihat, false); }

Chrome extension xhr request getting cancelled

筅森魡賤 提交于 2019-12-24 02:18:20
问题 I am trying to build a chrome extension which uses a xhr request to get response from a external api. I have set the permission for the extension as mention in the chrome extension document still xhr request is getting cancelled in network. manifest.json "browser_action": { "default_icon": "icon.png", "default_popup": "popup.html", "default_title": "Chrome extension title" }, "permissions": [ "activeTab", "storage", "https://*/" ] In popup.js var xhr = new XMLHttpRequest(); xhr.open("GET",