javascript - iPhone dashcode xmlhttprequest 无响应

标签 javascript iphone xmlhttprequest dashcode

我正在开发一个带有 dashcode 的 iPhone 网络应用程序。当我使用 iphone 模拟器浏览时,我的应用程序运行良好。当我将它部署到 Web 服务器时,我从未收到来自 XMLHttpRequests 的响应。这是我使用的代码:

function get(feedURL, handler) {
    var onloadHandler = function() { handler(xmlRequest); };    
    var xmlRequest = new XMLHttpRequest();
    xmlRequest.onload = onloadHandler;
    xmlRequest.open("GET", feedURL);
    var credentials = encodeBase64(_login.username + ':' + _login.password);
    xmlRequest.setRequestHeader("Authorization", "Basic " + credentials);
    xmlRequest.send();
}

当我附加一个 onreadystatechange 处理程序时,我可以看到请求进入状态 4。我还可以在我的服务器日志中看到这些请求。我还添加了一个“无缓存”请求 header ,但没有帮助。我在我拥有的托管包上的本地网络服务器上尝试了这个,但我没有任何运气让它工作。

最佳答案

黑暗中的一枪,但apple docs说这个。

the domain of the URL request destination must be the same as the one that serves up the page containing the script. This means, unfortunately, that client-side scripts cannot fetch web service data from other sources, and blend that data into a page. Everything must come from the same domain. Under these circumstances, you don't have to worry about security alerts frightening your users.

status 和 statusText 的值是什么?也可以尝试 getAllResponseHeaders() 获取更多信息。

此外,如果它只是您想要的基本身份验证,您可以像这样将它传递给 open():

open("method", "URL", asyncFlag, "userName", "password")

关于javascript - iPhone dashcode xmlhttprequest 无响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1326474/

相关文章:

javascript - 尽管文件上传,但文件上传进度事件未触发

javascript - 如何在提示中将 HTML 格式的用户输入转换为文本

javascript - 数据表样式不起作用

iphone - iOS - PayPal 集成 - "Invalid parameter Subtotal"错误

iphone - iphone5 IOS录音时如何使用振动?

javascript - 使用来自多个 XMLHttpRequest 的响应更新 DOM

javascript - 在 XML 文档中搜索某个元素/属性值并返回该元素

javascript - 通过多个页面的 FireBreath 插件

javascript - 为什么这个js数组函数不起作用?

iphone - 如何关闭内容 View 中的弹出 View ?