xmlhttprequest

How to receive POST data in python when using XMLHttpRequest()

荒凉一梦 提交于 2020-01-02 02:54:13
问题 I have two questions regarding receiving of data when using XMLHttpRequest(). Client side is in javascript. Server side is in python. How do I receive/process data on the python side ? How do I respond back to HTTP request? Client side var http = new XMLHttpRequest(); var url = "receive_data.cgi"; var params = JSON.stringify(inventory_json); http.open("POST", url, true); //Send the proper header information along with the request http.setRequestHeader("Content-type", "application/x-www-form

How to disable 'withcredentials' in HTTP header with node.js and Request package?

那年仲夏 提交于 2020-01-02 00:58:30
问题 Using node.js and the Request package from the browser (via browserify), I am using CORS to do a HTTP GET request on a separate domain. On the server, when I set 'Access-Control-Allow-Origin' to the wildcard '*' , I get the following error on the client: XMLHttpRequest cannot load .... A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true. Origin '...' is therefore not allowed access. The HTTP request header looks like this: Accept:*/*

Reading code from GitHub as text (raw) in a web page

北战南征 提交于 2020-01-01 19:14:32
问题 I'm trying to read some source code (C language) from my GitHub repository to be shown as text in my webpage. I can access the code in raw mode through https://raw.github.com. I'm using jQuery GET function to read the data but it doesn't work. Problem is related with XMLHttpRequest and Access-Control-Allow-Origin but, despite I found some related question on stackoverflow (XmlHttpRequest error: Origin null is not allowed by Access-Control-Allow-Origin) it didn't work for me. I tried

Safari AJAX bug - Failed to load resource

我们两清 提交于 2020-01-01 12:28:34
问题 since today I have a pretty strange bug in an web app I'm working on. I haven't done anything to the code and from one day to another this bug appeared: I execute AJAX requests (not with jquery but with normal js) to our local server running MAMP PRO. All works fine in chrome and firefox (testing on a mac). But in safari the request always throws an error: Failed to load resource: the network connection was lost When I try to load the url of the request manually (not via AJAX) everything

XMLHttpRequest CORS to Google Cloud Storage only working in preflight request

╄→尐↘猪︶ㄣ 提交于 2020-01-01 04:31:30
问题 I implemented browser based resumable uploads into Google's Cloud Storage using an XMLHttpRequest send to a server-side created resumable upload url. This works completely fine when disabling web security, which I did during development. But now in the real world, CORS keeps making trouble. I tried this with other browsers (without success), too, but sticked to chrome for further testing. Note: A fake.host entry in /etc/HOSTS is used to trick chrome into avoiding localhost-restrictions.

Internet Explorer: SCRIPT7002: XMLHttpRequest: Network Error 0x2f7d, Could not complete the operation due to error 00002f7d

寵の児 提交于 2020-01-01 04:16:50
问题 This problem is driving me nuts. Our web app uses HTTP POST to login users and now IE 10 is aborting the connection and saying: SCRIPT7002: XMLHttpRequest: Network Error 0x2f7d, Could not complete the operation due to error 00002f7d. Here are all the details I have IE version 10.0.9.16618, update version 10.0.6. I've also reproduced this on IE version 10.0.9200.16635, update version 10.0.7. The domain is using HTTPS. The problem doesn't occur on HTTP connections I've read that for some reason

JQuery $.post cross domain and credentials

◇◆丶佛笑我妖孽 提交于 2020-01-01 02:39:47
问题 I have written a web application which uses lot's of $.post calls with JQuery. Now I would like to send withCredentials: true with it to keep a session alive, what looks like this in $.ajax (and also works like this): $.ajax({ type: 'post', url: 'http://example.com/server/api.php', crossDomain: true, dataType: "json", xhrFields: { withCredentials: true }, data: { username : 'test', password : 'test' }, success: function (d) { $('body').html(d.status); } }); This is because I would now like to

Set headers on get request angular 2

独自空忆成欢 提交于 2020-01-01 02:16:12
问题 I try to set an Authorization header to a GET request to authenticate users to a rest API. I'm using Angular 2 RC1. (I'am a total beginner). getTest(){ let authToken = localStorage.getItem('auth_token'); let headers = new Headers({ 'Content-Type': 'application/json' }); headers.append('Authorization', `Bearer ${authToken}`); let options = new RequestOptions({ headers: headers }); return this._http .get(this._url,options) .map(res => console.log(res)); } I allow CORS in my backend. header(

XMLHttpRequest Vs HttpRequest

回眸只為那壹抹淺笑 提交于 2020-01-01 01:53:22
问题 Does anyone know, what an XMLHttpRequest enables a web page to do, which cannot be done using a normal HttpRequest ? 回答1: XMLHttpRequest in a standard javascript object that allows you to make HTTP Requests from the browser in javascript. HttpRequest is a server side object that represents a request to the server. In summary - one works in the browser, the other in the web server. They also have completely different roles. XMLHttpRequest is for fetching web resources within the browser.

Refused to set unsafe header “Origin” when using xmlHttpRequest of Google Chrome

人走茶凉 提交于 2019-12-31 12:36:20
问题 Got this error message: Refused to set unsafe header "Origin" Using this code: function getResponse() { document.getElementById("_receivedMsgLabel").innerHTML += "getResponse() called.<br/>"; if (receiveReq.readyState == 4 || receiveReq.readyState == 0) { receiveReq.open("GET", "http://L45723:1802", true, "server", "server123"); //must use L45723:1802 at work. receiveReq.onreadystatechange = handleReceiveMessage; receiveReq.setRequestHeader("Origin", "http://localhost/"); receiveReq