Discussion WinJS.xhr: timeout value

  • Thursday, April 05, 2012 2:25 PM
     
     

    Hello guys.

    I'm reading the docs about xhr and I've noticed that there's no way to pass the timeout through the object passed to the xhr method. According to the docs, out best option is to use the WinJS.Promise.setTimeout method, but this is not the same thing as changing the timeout property of the XMLHttpRequest object

    Here's a quick question: why doesn't the xhr method searches for a timeout property in the anonymous object it receives which gets passed to the XMLHttpRequest object used internally?


    Luis Abreu

All Replies

  • Friday, April 27, 2012 6:27 PM
     
      Has Code

    Hi Luis,

    You can do this yourself by providing a customRequestInitializer function in the options object:

    WinJS.xhr({
      customRequestInitializer: function(req) {
        //do something with the XmlHttpRequest object req
      }
    );

    Is this a workable solution for you, or would you still prefer the xhr code to try to inspect XmlHttpRequest properties and 'do the right thing'?

    Cheers,

    -Jeff

  • Friday, April 27, 2012 8:18 PM
     
     

    Yes, it will work Jeff!

    Unfortunately, the docs don't have any reference to that. 

    thanks.


    Luis Abreu

  • Friday, April 27, 2012 9:10 PM
     
     

    I'll send a note to the tech writer for WinJS.

    Thanks,

    -Jeff

  • Saturday, April 28, 2012 9:35 PM
     
     
    Thanks.

    Luis Abreu