title: Adding Request Headers to the XmlHttpRequest with Kendo UI Upload control
body: <p>I'm trying to use the code provided by Telerik to add request headers to the XHR, but I'm getting the following error.</p>
  
  <p>"0x800a139e - JavaScript runtime error: InvalidStateError"</p>
  
  <p>Here is the code</p>
  
  <pre><code>$(document).ready(function () {
                          $("#file").kendoUpload({
                              multiple: false,
                              async: {
                                  saveUrl: "save",
                              },
                              upload: onUpload,
  
                          });
                      });
  
  function onUpload(e) {
                          var xhr = e.XMLHttpRequest;
                          if (xhr) {
                              xhr.addEventListener("readystatechange", function (e) {
                                  if (xhr.readyState == 1 /* OPENED */) {
                                      xhr.setRequestHeader("X-Foo", "Bar");
                                  }
                              });
                          }
                      }
  </code></pre>