I am working on a tool for generating html files. The code is fairly simple. A user clicks a post button and the content from a textarea is sent to an endpoint. I have tried posting the html as a json string. Expected The saveContent method is called. The value from the textarea element is concatenated into a…
Tag: xmlhttprequest
.send(formData) Error “GET 404 …/upload.php (Not Found)”
i’ve found this code on a website for uploading files using javascript, but it doesn’t seems to work. Could somebody help me with that please? Index.php : And js : and upload.php : And now this issue : GET …/upload.php 404 (Not Found) and related code to issue : btw what is that “GET&#…
Get a response in chunks from express in browser
I’m building a progress bar for some long-running server-side tasks (up to a few minutes), and I’d like a way to display the progress of the task. I could use WebSockets or poll on intervals, but I don’t want to keep track of each task. Instead, I’d like to use long-polling and write p…
Why is php POST array empty for me in one instance and populated in another, both using XHR POST?
I am trying to write code that will check if username is already used, and I wrote some test code where my php $_POST array was populated. However, I modified the test code slightly for the ‘production’ code I am developing, and my $_POST array is empty. My first set of code, that is working, html…
JS style-changes don’t get applied when inside request
I want to make it such that an image on a website gets its “onclick” event disabled and a gray filter applied, if a certain file on the same domain is not found. I want to use purely JS and have tried this so far: I have the image initialized and displayed. Thus image.onclick = “” and …
How to make AJAX request in Hackerrank using JavaScript?
I open the Hackerrank example test and play around with methods one might use to make an AJAX call. XMLHttpReq, fetch, etc. None of them work; XHR and fetch methods are unavailable. First fetch: Hackerrank throws an error because fetch is not a function. I also tried window.fetch and global.fetch to no avail.…
Can’t make new fetch request after aborting previous
I need to change a parameters that defines what data should come from my requests, also this application needs to refresh on a regular time interval. If the user changes the parameter in the middle of an unfinished request things start to behave strange and some unexpected behavior occurs. So my approach was …
Axios change http to https
I have server that accept only http (no https). And when I call an api, axios automatically change http to https. I create axios instance here: But in browser http changes to https, so it become: https://xxx.xxx.xxx/api/v1/all and I get net::ERR_NAME_NOT_RESOLVED How can I prevent that? UPDATE Request Header:…
Is it possible to add a request header to a CORS preflight request?
I have a website that accesses an API from an external server (not the server that serves the website) via a plain XmlHttpRequest (see below). That API requires an API key for accessing the service to be added as request header. However, as these are CORS requests the browser first does a preflight request to…
Where to place async/await in this case?
EDIT: The problem was not the placement of the async/await per se, but the fact that I was trying to make a constructor asynchronous. I have looked through docs, read other questions and answers, but I still can’t get my head wrapped around what function to make async, and where to place the await, to g…