XmlHttpRequest on Tizen TV exits application

萝らか妹 提交于 2019-12-07 16:19:26

问题


I am currently developping an app for Samsung Tizen and WebOS TVs. For this, I am using Samsung's TOAST and Caph with angular1.

The generated .wgt is working fine on browser and TV Simulator, but on real device, the application exits when an XMLHttpRequest is sent.

Here is the code:

    var url = "grant_type=password&username=" + $scope.logInfos.loginEmail + "&password=" + $scope.logInfos.loginPassword;
    var xhr = new XMLHttpRequest();
    xhr.open('POST', 'https://myUrl/token');
    xhr.onreadystatechange = function() {
        xhr.onloadend = function() {
            if (xhr.response) {
                console.log("logged in");
            }
        };
    };
    xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xhr.send(url);

These lines are launched when the login form is submitted but at this moment the application exits. There are no error message in the console and no trace of the xhr in the network tab.

I tried changing HTTPS to HTTP in case this was the problem but it did nothing.

Could you please help?


回答1:


Don't forget to add privilege and allow domains in your config.xml

<access origin="*" subdomains="true"></access>
<tizen:privilege name="http://tizen.org/privilege/internet"/>



回答2:


After searching, it appears TOAST deleted the following line:

    <access origin='*' subdomains='true'/>

All I had to do to make my app work was adding this line again into config.xml file. Problem solved!



来源:https://stackoverflow.com/questions/40737184/xmlhttprequest-on-tizen-tv-exits-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!