问题
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