Tizen TV 上的 XmlHttpRequest 退出应用程序

标签 xmlhttprequest toast tizen samsung-smart-tv

我目前正在为三星 Tizen 和 WebOS 电视开发应用程序。
为此,我将三星的 TOAST 和 Caph 与 angular1 一起使用。

生成的 .wgt 在浏览器和电视模拟器上运行良好,但在真实设备上,应用程序在发送 XMLHttpRequest 时退出。

这是代码:

    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);

这些行在提交登录表单时启动,但此时应用程序退出。控制台中没有错误消息,网络选项卡中也没有 xhr 的踪迹。

我尝试将 HTTPS 更改为 HTTP,以防这是问题,但它什么也没做。

能否请你帮忙?

最佳答案

不要忘记在 config.xml 中添加权限并允许域

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

关于Tizen TV 上的 XmlHttpRequest 退出应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40737184/

相关文章:

javascript - 如何使用 javascript 中的 http.post 将图像发送到服务器并在 mongodb 中存储 base64

reactjs - Toast 未渲染(react-toastify 组件)

android - 在 Android axios (XMLHttpRequest) 上使用阿拉伯语和波斯语在 React Native 中损坏的字符

javascript - xmlHttpRequest .open() 方法中的参数 "true"

java - 为什么这个 toast 在不应该出现的时候出现了?

xmlhttprequest - 在 Web View 上显示来自 telnet 接口(interface)的高速数据的最佳方式?

html - Tizen - 如何更改按钮字体大小 - 已修复

Tizen 模拟器 - 没有可安装的平台

node.js - 在Cloud9中使用socket.io总是得到xhr-polling传输方式

android - 微调消息问题