Category : xmlhttprequest

var request = new XMLHttpRequest(); request.open(‘GET’, url, true); request.setRequestHeader(‘Content-Type’, ‘application/x-www-form-urlencoded;’); request.onload = function () { if (this.status >= 200 && this.status < 400) { var html = this.response; console.log(html); } }; request.send(‘termo=’ + termo); Hi, I have this code to make an ajax call. The code is working fine, and the response is correct. But ..

Read more

I’m trying to make a request to an API (a public one and I can prove it) that I don’t own or operate. Code below: const validateMc_name = (event) => { // Check if entered MC username exists var http = new XMLHttpRequest(); http.open( "GET", `https://api.mojang.com/users/profiles/minecraft/${mc_name}` ); http.onreadystatechange = function () { if (mc_name === ..

Read more

Wassup my fellow programmers, I ran into a problem while trying to create a file upload and really don’t know what the problem is. So I have a file upload form w/ a progress bar (HTML): <form class="form" id="uploadForm"> <label class="btn btn-sm btn-secondary dark" id="myfile" name="myfile" for="ufile"> <i style="margin-right: 13px;" class="fa fa-file" aria-hidden="true"></i>Choose File… </label> ..

Read more

You must be familiar with XMLHttpRequest of JavaScript. Here’s my function, function loadData(url, data, div){ var http = new XMLHttpRequest(); var formData = new FormData(); if (data) { data = […data]; data.forEach=post=>{ formData.append(‘x1’, post) } } http.open("POST", url, true); http.send(formData); http.onprogress=(e)=>{ console.log(`${e.type}: ${e.loaded} bytes transferredn`); } http.onload=()=>{ return http.responseText; } } loadData(‘/banner.php’, [1,3,58], ‘export’) this ..

Read more