Firefox OS packaged apps and XMLHttpRequests

前端 未结 4 1600
日久生厌
日久生厌 2021-01-03 09:25

I\'ve been looking into packaged apps for Firefox OS and I\'m relying on the Simulator since I don\'t have a build of the OS on a device. I\'m having trouble with XHR reque

4条回答
  •  鱼传尺愫
    2021-01-03 09:47

    For Backbone or other Javascript framework using JQuery $.ajax under the hood use:

    $.ajaxSetup( {
        xhr: function() {return new window.XMLHttpRequest({mozSystem: true});}
    });
    

    I don't think that you need to use CORS. My app is working fine in simulator without CORS but fails to call remote REST server if launched on local server.

    Be aware that if you forgot to set

    dataType: "text"

    for some $.ajax calls (for example load html template) you can get XMLDocument as a result while desktop browsers returns string.

提交回复
热议问题