Error encountered in IE9 with goog.net.IFrameIO: Access to content document denied

My current project involves using goog.net.IframeIO to facilitate file uploads and receiving a JSON response from the server once the uploaded file is processed. However, I have encountered an issue specifically on IE9 where it throws an error "Access Denied to content document" and then prompts to save/open the JSON response. Below are snippets of the HTML and JS code I am working with:

HTML Code:

<form action="/" enctype="multipart/form-data" method="POST" id="upload-form">
  <input type="file" name="selected-file" id="selected-file">
  <div role="button" class="test-button>Upload</div>
</form>

JS Code:

test.prototype.uploadFile = function() {
  // Implementing IframeIo to simulate AJAX for server form submission.
  var form = /** @type {HTMLFormElement} */ (goog.dom.getRequiredElement(
      'upload-form'));

  var io = new goog.net.IframeIo();
  goog.events.listen(io, goog.net.EventType.COMPLETE, goog.bind(this.processResponse_, this, io));
  io.sendFromForm(form, '/uploadfile');
}

test.prototype.processResponse = function(io) {
  if (!io.isSuccess()) {
    alert('iframeio error encountered:' + io.getLastError());
    return;
  }
  var response = null;
  try {
    response = io.getResponseJson();
    ..
  } catch (error) {
    ....
}

I prefer utilizing Closure library rather than other libraries for this task. Additionally, I've reviewed discussion threads like Fallback AJAX file upload for Internet Explorer, however, was unable to comment on the accepted answer.

[Troubleshooting]: Upon investigation, I noticed that the method goog.net.IframeIo.prototype.onIeReadyStateChange_() is being invoked with various ready states such as loading, interactive, and finally complete, but fails to retrieve the content document from the iframe created in IE.

HTTP Request Headers: Accept: text/html, application/xhtml+xml, / Content-Type: multipart/form-data Accept-Encoding: gzip, deflate

HTTP Response Headers: X-Frame-Options: SAMEORIGIN Content-Type: application/json; charset=utf-8

Answer №1

When dealing with the IframeIO library on IE versions prior to 11, an iframe is generated for the upload of files, and the HTTP response is then posted to it.

However, in IE9/10 (uncertain about versions 8 or 11), the iframe does not accept HTTP responses with a content-type of JSON. To resolve this, the response's content-type must be adjusted to "text/plain" specifically for IE9/10 in order to function properly.

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

What is the process for configuring the global warning level in ESLint?

My current setup involves using WebStorm and the ESLint configuration provided by Airbnb. I'm curious if there is a way to have ESLint errors displayed in a more subtle manner instead of the harsh red color, or perhaps make all ESLint rules warnings ...

The issue with logging out feature

Operating an ASP.NET Web application, I have a Logout feature implemented in JavaScript. However, my current code closes the browser upon Logout, which is not the desired behavior. Instead, I am looking to clear cookies/session and redirect the user to the ...

Filtering an object based on keys within an ng-repeat loop

I need help with displaying only the items listed in defaults and excluding the others. <ul ng-controller="Ctrl" class="dropdown-menu"> <li ng-repeat="(key, value) in Employee.KeyValue | filter:DefaultKeys(key) ">{{key}}</li> </ul ...

Issue with managing cursor location using readline in Node.js

Currently, I am developing a console application in Node.js utilizing the readline module to manage cursor positions and obtain user input. Below is a custom library I have created for this purpose: // ReadLine.js const readline = require("readline&qu ...

Feeling unsure about the concepts of scoping and the "this"

Recently, I came across a code snippet at this source: : var CounterButton = function(el){ this.$el = $(el); this.counter = 0; this.bindEvents(); this.myVal = 1; } CounterButton.prototype.bindEvents = function(){ this.$el.click(this. ...

What could be the reason behind the application experiencing crashes while utilizing express-rate-limit?

I am utilizing version 6.0.1 of the express-rate-limit package to control the number of request hits, and I referenced the express-rate-limit documentation available at https://www.npmjs.com/package/express-rate-limit However, I am encountering a crash in ...

Utilizing AJAX to load a WAV file

One of the tasks I'm working on involves a collection of audio files. When a file from this list is clicked, I want JavaScript to load and display the waveform of that specific audio file. The following function is responsible for drawing the wavefor ...

Discovering the significance of a function's scope

I'm a bit confused about how the answer is coming out to be 15 in this scenario. I do understand that the function scope of doSomething involves calling doSomethingElse, but my calculation isn't leading me to the same result as 15. function doSo ...

Empty space on the edge of the mobile screen in Next.js causes usability issues

Currently working on a frontend project using Next.js and Tailwind. Encountered an issue where there is extra space on screens with a width less than 500px. For instance, if the screen width is 400px, there will be an additional 100px of deadspace. Simila ...

The Highcharts tooltip is not showing the correct text value, but instead showing 'undefined'

My data includes text values with corresponding score values (value X and value Y). I can plot a dot at the intersection of X and Y values. Hovering over the dot shows the location on x,y coordinates, but for the corresponding text value, it displays as un ...

Can information be saved to a JSON file without using a server-side language?

Previously, I've come across questions where the recommended solution involves using a server-side language. However, since I don't have knowledge of a server-side language yet, I was curious to know if it's possible to achieve this with my ...

Making changes to JSON format post $.get function

Struggling to make sense of the JSON properties I receive from the server. Any advice on how to change the format would be greatly appreciated. Here is a snippet of the received data: [ { "date": "2006-07-01T00:00:00.000Z", "date_processed": "2 ...

Offspring of div should have equal height without the top and bottom padding

Looking to ensure that the height of child divs matches the height of the parent divs. Currently, the divs expand as the page is resized. This is for search results, so there are multiple identical code blocks. function matchHeight() { $result = $(&a ...

Tips for verifying the status and triggering a function with a delay in a React component

I have a scenario where I want to execute a function only if the state remains unchanged after being updated by a database fetch. Here's what I currently have: const [value, setValue] = useState(false) const func = () => { ... } setTimeout(()=&g ...

Issue with detaching Ember and jQuery plugins

I have encountered an issue in my Ember app while attempting to update the DOM by detaching an element and appending it elsewhere. var comp = Ember.$(this.element).detach(); Ember.$("#some-sec").append(comp); After performing this operation, the previous ...

Why does Drupal's Advagg display several css and js files?

After installing the Advag module, I noticed that it is combining files, but there seems to be an issue: <link type="text/css" rel="stylesheet" href="/sites/default/files/advagg_css/css__sqX0oV0PzZnon4-v--YUWKBX0MY_EglamExp-1FI654__IOPiOtulrIZqqAM0BdQC ...

Which properties are missing from this type?

I received the following message: Issue with 'Motorvoertuig' class implementing 'Voertuig' interface. Error: Type 'Motorvoertuig' is missing properties from 'Voertuig': toonMerk, wieIsDeEigenaar However, the ...

You may encounter issues with invoking methods on a JavaScript object in Node.js after using res.send for response sending

Exploring Context and Design Overview Currently, I am utilizing a library known as Tiff.js to seamlessly load Tiff images on a designated webpage. The usage of this library extends both to the server-side and client-side functionalities. On the server end ...

Creating a Form Layout with Bootstrap - Organizing Text Boxes and Text Areas

https://i.sstatic.net/oqRwR.jpg In the image above, I need to adjust the position of the textbox to align it with the TextArea. Is there a Bootstrap class that can help me achieve this? My current version of Bootstrap is 3.3.6. HTML &l ...

Guide on adjusting the spotlight(s) based on the camera's location in Three.js?

I'm looking to create a dynamic spotlight that moves along with the camera. The code I have currently only maintains the spotlight at the exact position of the camera: var pointLight = new THREE.PointLight( 0xffffff, 1, 200 ); pointLight.position = c ...