javascript - Why is this XMLHTTPRequest aborted before going to the server?


I maintain a web app that uses CKeditor in conjunction with simogeo Filemanager. At some point (I am, unfortunately, not sure when) the file upload functionality stopped working. It's not a server code issue (at least not directly) because the XHR request is never sent to the server. Beyond that, though, the issue is difficult to diagnose because I don't get much in the way of information from the browser when the request fails.

To simplify debugging I am using a modified version of the AJAX file upload sample from here:

if ( isset( $_FILES['our-file'] ) ) {
    echo 'You uploaded ' . $_FILES['our-file']['name'];


<!DOCTYPE html>
<html lang="en">
  <meta charset="utf-8" />
  <title>Ajax upload form</title>

<form action="index.php" method="post" enctype="multipart/form-data" id="form-id">

<p><input id="file-id" type="file" name="our-file" />
<input type="submit" value="Submit" /></p>

var form = document.getElementById('form-id');
form.onsubmit = function() {
  var formData = new FormData(form);
  var action = form.getAttribute('action');
  sendXHRequest(formData, action);
  return false;

function sendXHRequest(formData, uri) {
  try {
    var xhr = new XMLHttpRequest();
    xhr.addEventListener('readystatechange', evtXHR , false);
    xhr.addEventListener('timeout', evtXHR , false);
    xhr.addEventListener('error', evtXHR , false);'POST', uri, true);
    xhr.timeout = 3000;
  } catch (err) {
    result.innerHTML = err;

function evtXHR (evt) {
  var status = null;

  try {
    status =;
  catch(e) {

  var result = document.getElementById('result');
  var msg = result.innerHTML + '<hr>';
  if (status == '200' && {
    msg += '<p>Results from the server:</p><pre>' + + '</pre>';
  msg += '<p>XMLHTTPRequest Event ' + evt.type + '<br>';
  msg += 'XMLHTTPRequest Status ' + + '<br>';
  msg += 'XMLHTTPRequest Readystate ' + + '</p>';
  result.innerHTML = msg;

<pre id="result"></pre>


Upon form submission (xhr.send()) the request dies without any kind of helpful error. Firefox kills the request and indicates it has been aborted (from the Firebug net panel). IE similarly kills the request with the following error in the console:

XMLHttpRequest: Network Error 0x2efe, Could not complete the operation due to error 00002efe.

Googling has offered little in the way of direction. The few possible explanations were too many requests, overlapping requests cancelling each other out, or request timeouts. None of those appear relevant. Mozilla has a note about stopped requests that seems potentially helpful, but isn't directly related to my issue.

The issue only crops up when submitting over AJAX using a POST request that includes a file. Submitting a regular, non-AJAX request works fine. Submitting an AJAX request without a file goes through just fine. Submitting a GET request works, but that severely limits the data size. Submitting the request to an HTML document instead of a PHP script seems to work around the issue.

On a server with a very similar configuration I an unable to duplicate the issue. I have, however, reproduced the issue on the same server using two different domains. And the issue can be duplicated on two different client computers using a variety of browsers.

So ... what now? Looking for either an answer or at least a suggestion for how to debug the issue.

You can find the simple upload script here:




Post resolved as a server-side issue in chat - shamefully restarting apache cleared the issue :/ but for anyone interested the transcript is available here. There may (or not) be useful dialogue for anyone with a similar issue.

People are also looking for solutions to the problem: php - How to select a specific value plus extra random values in a query?


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.