Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-5203

Using XmlHTTPRequest.open on WP8 raises a TypeError

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.1.0
    • 3.3.0
    • None
    • Windows Phone 7 + 8

      Windows 8, MS Visual Studio Express 2012 for Windows Phone version 11.0.60610.01 Update 3. .NET version 4.5.50709. Weinre 2.0.0-pre-HH0SN197

    Description

      Using the cordova-app-hello-world code on a WP8 device, connected to the device through weinre, trying to use XMLHTTPRequest like this:

      var xhr = new XMLHttpRequest();
      xhr.open('GET', 'js/index.js', true);
      xhr.send();
      console.log(xhr.responseText);
      

      An error is raised at xhr.open: TypeError: Object doesn't support property or method 'addEventListener'

      The same code on iOS runs through and shows me the content of index.js.

      Changing the call to:

      var xhr = new XMLHttpRequest();
      xhr._url = 'js/index.js';
      xhr.send();
      console.log(xhr.responseText);
      

      Returns the expected result.

      I also noticed that XMLHttpRequest.prototype.open does not match the code in cordovalib\XHRHelper.cs:

      XMLHttpRequest.prototype.open
      function() {
      var result;
      callBeforeHooks(hookSite, this, arguments);
      try {
      result = func.apply(this, arguments);
      } catch (e) {
      callExceptHooks(hookSite, this, arguments, e);
      throw e;
      } finally {
      callAfterHooks(hookSite, this, arguments, result);
      }
      return result;
      }
      

      GitHub repository with the code I used: https://github.com/gaqzi/cordova-wp8-xhr-test

      Attachments

        Activity

          People

            sgrebnov Sergey Grebnov
            gaqzi Björn Andersson
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: