JavaScript ReferenceError: FormData is not defined as a variable

I am facing an issue with the code snippet below. The script is designed to send 2 variables and a file to a PHP script for uploading to a server. While everything works fine in Firefox and Chrome, Opera throws an error "ReferenceError: Undefined variable: FormData".

I am unable to test in IE or Safari due to my dependency on the File API. Although there are other functions within the script, only these 2 are crucial as they are where the error originates.

datumActiviteit = "testxx";
naamActiviteit = "testyy";

function sendFiles() {
try{
    var imgs = document.querySelectorAll(".obj");
    for (var i = 0; i < imgs.length; i++) {
        new BestandenUploaden(imgs[i],imgs[i].file);
    }
}
catch(ex){alert(ex);}

}

function BestandenUploaden(img,file){
try{
    var formData = new FormData();
    formData.append("activiteit", naamActiviteit);
    formData.append("datum", datumActiviteit);
    formData.append("bestand", file);

    var oXHR = new XMLHttpRequest();
    oXHR.open("POST", "launcherV2.php");

    oXHR.onreadystatechange = function (oEvent) {
        if (oXHR.readyState==4 && oXHR.status==200) {
            if (oXHR.responseText == "continue") {
                img.parentNode.lastChild.style.opacity = "1.0";
                img.parentNode.lastChild.style.backgroundColor = "transparent";
                img.parentNode.lastChild.style.backgroundImage = "url(../afbeeldingen/rocket/complete.png)";
            }
            else {
                window.alert(oXHR.responseText);
            }
        }
        else{
            window.alert("readyState or status error :", oXHR.statusText);
        }
    };

    oXHR.send(formData);

}
catch(err){alert(err)};


};

Any insights into why only Opera(v11.62) would be throwing this particular error?

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Generate a sparse array using only a single line of code

Is it possible for JavaScript to create a sparse array similar to what Bash can do in one line? names=([0]="Bob" [1]="Peter" [20]="$USER" [21]="Big Bad John") § Creating Arrays Can JavaScript achieve the same with sparse arrays? ...

Here's a guide on using a button to toggle the display of password value in Angular, allowing users to easily hide

I have successfully implemented an Angular Directive to toggle the visibility of password fields in a form. However, I am facing an issue with updating the text displayed on the button based on the state of the input field. Is there a way for me to dynami ...

Is there a way to determine if a unique value is present in a jQuery array?

$.each(date_range, function(kr, time) { alert('time' + '=>' + time) alert(data_d.indexOf(time) != -1); if (time == timestamp) { data_d.push([timestamp, v.kreditbetrag]); } else { data_d.push([time, 0] ...

Is there a way to create animated CSS box-shadow depth using jQuery or CSS3 transitions?

This code snippet applies delays but doesn't seem to update the style changes until the loop completes: for (i=20;i>=0;i--) { var boxShadow = i+"px "+i+"px "+i+"px #888"; $('article').css("box-shadow", boxShadow); ...

axios is refusing to update or be uninstalled

Despite my efforts to update the axios package, it stubbornly refuses to upgrade to the latest version. I'm currently running a node server using pm2 I've attempted the following: npm uninstall axios npm i axios and even npm update axios ...

Enhanced appearance with asynchronous functions at the top level

Is there a method to incorporate async top level with prettier? I attempted to exclude my await top level using /prettier ignore, however, prettier seems to be ignoring this line... ...

Using a conditional statement to generate objects within a TypeScript loop

I'm currently working on a loop within my code that involves adding dates from an array (dates) as key/value pairs ("date":"dates[i]") to objects in another array (values). values.forEach((obj, i) => obj.date = dates[i]); The issue arises when ...

Adjust the viewing area dimensions on a web browser

Recently, while testing a web application page I developed with Selenium, I came across an interesting issue. After using the JavaScriptExecutor in Selenium to get the viewport size, I found that it was different for Chrome, IE, and Firefox. The sizes wer ...

The rule '@typescript-eslint/no-implicit-any' could not be located within Storybook JS's definition

Encountering an error after modifying the code generated by running Storybook.js. Following these instructions: https://gist.github.com/shilman/bc9cbedb2a7efb5ec6710337cbd20c0c Integrating StorybookJS into an existing project, only executed these command ...

The issue at hand involves Javascript, Ajax, latte, and Presenter where there seems to be a restriction on using GET requests for a file located

I have a query. I’ve been given the task of adding a new function to our web application. It was built on PHP by someone else, so it's proving quite challenging for me to debug as I am not familiar with this technology. I’m attempting to incorpor ...

Issue with Bootstrap Scrollspy: Scrollspy function not functioning as expected

I need help with creating a one-page website where the navbar links change based on the section of the page you are on. I tried implementing it using HTML, but it didn't work out as expected. The code I used was within the container holding different ...

Suggestions for a JavaScript tool that automatically crops images

Is there a tool available, either browser-based or in Java, that can analyze an uploaded image, identify different characters within it, and crop them out into separate images? For instance, if this image contains three unique runic symbols, I would like ...

The `history` model cannot be recompiled to overwrite it

I encountered an issue while attempting to save the query, as it returned an error stating that I cannot overwrite the model once compiled. Below is my models file: const mongoose = require("mongoose") const history = new mongoose.Schema({ search_n ...

The function isModified in mongoose.Schema is not recognized

'The issue I'm facing is that user.isModified is not recognized as a function, and I keep receiving the same error message. I am unsure of where to even begin addressing this problem. userSchema.pre('updateOne', function(next) { con ...

Using JavaScript, implement the array.filter method on a JSON array to retrieve the entire array if a specific property matches a given

Help needed with filtering an array: In the user_array, there are arrays that need to be compared to see if the header_info.sap_number matches any value in the valid_sap_number array. If a property value matches anything in the valid_sap_number array, th ...

Angular2 Pipe - Currency code

Within the realm of angular2, pipes are utilized to format numbers. For instance: {{selectedTeam.teamSalary | currency: 'USD':true}} This results in an output like $152,524,668.00 The documentation on Angular2 Pipes lacks specific details, lea ...

Enforcing quoted keys in a Javascript object

There's often confusion around the difference between obj = {"foo" : "bar"} and obj = {foo: "bar"} The explanation is that using quotes follows proper JSON syntax, while no-quotes is just Javascript syntactic sugar. Now, my query is how to conve ...

How to loop through an array in javascript and calculate the total?

Hey there! I'm a bit confused and couldn't find the solution anywhere. Are you able to take a look at my code and point out what's wrong with it? I promise, I'm not trying to get you to do my homework! Question: Loop through an array F ...

What is the process for updating the list to retrieve fresh data from the service?

I am currently in the process of calling a web service to retrieve data and display it in a list using directives. Upon loading my fiddle, I successfully load data from a JSON file. The data is displayed correctly in the list. If I click the delete butto ...

What Causes the Payload to be Empty in My Redux Action?

I encountered a problem while working on my React project with Redux (not Redux Toolkit). The issue is that the payload in my Redux action is turning out to be null. I am utilizing Firebase for authentication purposes and when attempting to dispatch the se ...