xmlhttprequest

“getElementById not a function” when trying to parse an AJAX response?

最后都变了- 提交于 2020-01-08 22:40:25
问题 I'm running GM_xmlhttpRequest (in a Greasemonkey script) and storing the responseText into a newly created HTML element: var responseHTML = document.createElement('HTML'); ... onload: function() { responseHTML.innerHTML = response.responseText; } And then I am trying to find an element in responseHTML : console.log(responseHTML.getElementsByTagName('div')); console.log(responseHTML.getElementById('result_0')); The first works fine, but not the second. Any ideas? 回答1: getElementById is not a

POST 405 (Method Not Allowed)

扶醉桌前 提交于 2020-01-07 09:02:26
问题 I am trying to build a Chrome Extension that uses the BOX api. I am able to authentificate and enable access for the app, and then I extract and store the access token from the URL. The next step would be to upload a file to box, and I am trying to use the code they provided on the website with small modifications: //file - a csv file I created before var uploadUrl = 'https://upload.box.com/api/2.0/files/General'; // The Box OAuth 2 Header. Add your access token. var headers = { Authorization

POST 405 (Method Not Allowed)

只谈情不闲聊 提交于 2020-01-07 09:01:27
问题 I am trying to build a Chrome Extension that uses the BOX api. I am able to authentificate and enable access for the app, and then I extract and store the access token from the URL. The next step would be to upload a file to box, and I am trying to use the code they provided on the website with small modifications: //file - a csv file I created before var uploadUrl = 'https://upload.box.com/api/2.0/files/General'; // The Box OAuth 2 Header. Add your access token. var headers = { Authorization

Handle xhr with ASP.NET

别来无恙 提交于 2020-01-07 04:17:28
问题 I would like to send a POST asynchronously from client side (JavaScript) to server side (ASP.Net) with 2 parameters: numeric and long formated string. I understand the long formated string must have encodeURIComponent() on it befor passing it. My trouble is I want to embed the long encoded string in body request and later open it from C# on server side. Please, can you help me? I'm messing too much with ajax, xhr, Request.QueryString[], Request.Form[], .... 回答1: First, create an HTTPHandler:

XMLHttpRequest cross domain throws error

a 夏天 提交于 2020-01-07 02:12:43
问题 I made a 'voting' API for a topsite for the sites registered to use. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script type="text/javascript"> var id = 1; $(document).ready(function(){ $.getJSON("http://mysite.com/index.php?page=vote", { id: id, hasVoted: 'unknown' }, function(data) { if(data == 2) { window.location.replace("http://mysite.com/index.php?page=vote&id=" + id); } }); }); </script> Basically, I give the user's their ID and then they

XMLHttpRequest cross domain throws error

与世无争的帅哥 提交于 2020-01-07 02:12:37
问题 I made a 'voting' API for a topsite for the sites registered to use. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script type="text/javascript"> var id = 1; $(document).ready(function(){ $.getJSON("http://mysite.com/index.php?page=vote", { id: id, hasVoted: 'unknown' }, function(data) { if(data == 2) { window.location.replace("http://mysite.com/index.php?page=vote&id=" + id); } }); }); </script> Basically, I give the user's their ID and then they

receiving file in node-express uploaded with xhr

喜你入骨 提交于 2020-01-06 20:18:03
问题 I have a xmlhttprequest which uploads the file and I am trying to receive it in my node-express server. but for some reason I am not able to retrieve the file content in the server. Not sure where I am missing it. app.post('/api/uploadfiles', function(req, res) { console.log("apicalled"); console.log(req); console.log(req.body); console.log(req.files); console.log(JSON.stringify(req.files)); }); 回答1: In order for you to see the files, you will need to add another middleware that parses multi

XMLHTTPrequest sending empty post

懵懂的女人 提交于 2020-01-06 19:37:35
问题 I've done a lot of times before, so I'm honestly confused why this is failing to pass anything. I've tried printing results (script gets a response and prints the file). function submit_form_inpage(path, data, watchForChange){ alert(data); watchForChange = watchForChange || false; var request = new XMLHttpRequest(); request.open('POST', path, true); request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); if (watchForChange == true) { request

AngularJS $http.get reports XMLHttpRequest failure

丶灬走出姿态 提交于 2020-01-06 15:18:27
问题 I'm trying to learn to use $http.get requests in AngularJS for a web app that I am writing. I have a locally hosted server that has some API that I have written. When I try to run my Angular page I can see in my server's console that the GET request has been made however nothing loads in the browser. Upon inspecting the browser's console I find this error message: XMLHttpRequest cannot load http://127.0.0.1:8080/api/range/?nmax=5&a_max=100&b_max=200, No 'Access-Control-Allow-Origin' header is

Synchronous XMLHttpRequest on the main thread is deprecated. Any alternative to send request before opening new page?

左心房为你撑大大i 提交于 2020-01-06 14:46:17
问题 as the synchronous XMLHttpRequest is being deprecated, I'm wondering if there is some kind of alternative to simulate similar behaviour as non-blocking asynchronous XMLHttpRequests are not suitable for some cases. I'm talking in particular about a case where I need to send a Post Request to the server, when an user clicks a hyperlink. Using PreventDefault is not an option here. With Synchronous XMLHttpRequest I can use an OnClick event, send the Request, and once it's done the browser