xmlhttprequest

Vbscript msxml12.XMLHTTP error handling

依然范特西╮ 提交于 2019-12-21 21:28:30
问题 I use this vbscript code, to download web page: Dim oXML Set oXML = CreateObject("msxm12.XMLHTTP") oXML.Open "GET", "mysite.com", False oXML.Send If there is no such web site, I get an error 80004005, Unspecified error at line "oXML.Open ..." How can I handle this error in vbscript? I want to catch this error and show msgbox with my error, i.e. web page is not available. 回答1: There are at least three possible points of failure in your script. CreateObject may fail; e.g. if you use msxml12

node.js - XMLHttpRequest, get header informations

余生长醉 提交于 2019-12-21 20:55:00
问题 I want to get the headers of the website "http://facebook.com". This should be a 302 Moved Permanently and I want to call the referred link which is provided in the response header. Here is my code: var req = new XMLHttpRequest(); req.open('GET', "http://facebook.com/", false); req.send(null); var headers = req.getAllResponseHeaders().toLowerCase(); console.log(headers); And here is the error message: /home/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:230 for (var i in response.headers)

node.js - XMLHttpRequest, get header informations

断了今生、忘了曾经 提交于 2019-12-21 20:54:06
问题 I want to get the headers of the website "http://facebook.com". This should be a 302 Moved Permanently and I want to call the referred link which is provided in the response header. Here is my code: var req = new XMLHttpRequest(); req.open('GET', "http://facebook.com/", false); req.send(null); var headers = req.getAllResponseHeaders().toLowerCase(); console.log(headers); And here is the error message: /home/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:230 for (var i in response.headers)

How do you load a JSON in a Stackblitz project?

三世轮回 提交于 2019-12-21 20:48:54
问题 I'm working in Stackblitz and one of my files is a JSON file with some data. I want to get this JSON data into my javascript file index.js . But how? When I try loading it with xhr , like this: function loadJSON(callback) { var xobj = new XMLHttpRequest(); xobj.overrideMimeType("application/json"); xobj.open('GET', './data.json', true); // Replace 'my_data' with the path to your file xobj.onreadystatechange = function () { if (xobj.readyState == 4 && xobj.status == "200") { // Required use of

What is the point of request.mode in the fetch API, especially with respect to cors?

左心房为你撑大大i 提交于 2019-12-21 19:43:30
问题 Looking at the new fetch API, you can specificy a mode field in the request. From Mozilla: The mode read-only property of the Request interface contains the mode of the request (e.g., cors, no-cors, same-origin, or navigate.) This is used to determine if cross-origin requests lead to valid responses, and which properties of the response are readable. And then how to use it: var myHeaders = new Headers(); var myInit = { method: 'GET', headers: myHeaders, mode: 'cors', cache: 'default' }; fetch

DOM parsing in JavaScript

扶醉桌前 提交于 2019-12-21 18:12:15
问题 Some background: I'm developing a web based mobile application using JavaScript. HTML rendering is Safari based. Cross domain policy is disabled, so I can make calls to other domains using XmlHttpRequests. The idea is to parse external HTML and get text content of specific element. In the past I was parsing the text line by line, finding the line I need. Then get the content of the tag which is a substring of that line. This is very troublesome and requires a lot of maintenance each time the

Is it safe to bypass CSRF protection for XHR? (Rails)

假如想象 提交于 2019-12-21 17:05:36
问题 A component of our webapp is (more-or-less) an SPA. i.e. it runs using javascript, and doesn't generate any page views or refreshes. This can cause CSRF tokens to go stale. Particularly for mobile phone users, who might switch the browser off and open it a few days/weeks later. This SPA occasionally needs to POST updates to the server. We see some javascript POST requests that generate a 422 error, with a warning about CSRF protection. I'm pretty sure that the CSRF token is present, but is

Problem: XMLHttpRequest - handle server connection lost

自闭症网瘾萝莉.ら 提交于 2019-12-21 14:12:39
问题 How do I handle the scenario where I making a synchronous request to the server using XMLHttpRequest and the server is not available? xmlhttp.open("POST","Page.aspx",false); xmlhttp.send(null); Right now this scenario results into a JavaScript error: "The system cannot locate the resource specified" 回答1: Ok I resolved it by using try...catch around xmlhttprequest.send : xmlhttp.open("POST","Page.aspx",false); try { xmlhttp.send(null); } catch(e) { alert('there was a problem communicating with

how to load image in background?

风格不统一 提交于 2019-12-21 14:09:08
问题 Problem: I am creating an album.So on every press of time "NEXT" button I am loading new Images. What I want to achieve is, I want to switch from old image to new image only once the new images has been downloaded fully from server. Actually I dont want to show partial images while loading. Is there any solution? PS SIMILAR QUESTION but this is for Iphone. I need for browser? 回答1: Just make a new image via javascript, and only show the image after the onload has fired. This will make sure you

XMLHttpRequest - freeing after use?

浪尽此生 提交于 2019-12-21 12:56:08
问题 I'm writing a browser app that would be entirely AJAX-driven (first time in my life), that means: it will be one page staying in the browser, loading program components as needed browser history will be, well, none. page will not be refreshed at all My concern is what should I do about XMLHttpRequests, since I'm primarily C++ programmer, being taught that when you write a statement like x = new XMLHttpRequest(); you need to delete it afterwards. This question is entirely about memory