【问题标题】:WP8 emulator local ajax calls not workingWP8 模拟器本地 ajax 调用不起作用
【发布时间】:2013-10-03 07:51:10
【问题描述】:

我正在将一个在 android 和 ios 上运行良好的 html5 Phonegap 应用程序转换为 wp8 应用程序,目前我的 ajax 调用不工作..奇怪的远程 ajax 调用工作。这是有效的ajax调用:

function textSearch() {
    $.ajax({ 
        type: "POST",
        url: baseUrl + "ajax/AppService.aspx/GetByFullSearch",
        data: JSON.stringify({"query":$('#search_location').val()}),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (all) {
            searchResult = all.d;
            showLocationResult();
        }
    }); 
};

这是我的本地 ajax 调用不起作用:

$.ajax({url:"./pages/result.html" ,success:function(result){
    $("#maincontents").html(result);
}});

这个我试过了,还是不行

$.ajax({
         url: "./pages/result.html",
         cache: false
        })
     .done(function( html ) {
     alert("hello?");
        $( "#maincontents" ).append( html );
  });

我从 ajax 收到如下错误:

error:function(jqXHR,textStatus,errorThrown ){
    alert(textStatus);
},

textStatus 返回“错误”..... 模拟器使用 ie10,我研究过重置 ie10 设置,更新了模拟器, 试图添加数据类型:'html',缓存:假,没有运气

希望有人知道这让我发疯!

【问题讨论】:

标签: jquery windows-phone-8


【解决方案1】:

设法解决了这个问题,phonegap 文件被炸毁了:

https://issues.apache.org/jira/browse/CB-3761

将 Cordova.js 的第 6258 行从:

"File", "readResourceAsText", [alias._url]

到:

"File", "readResourceAsText", [alias._url, "", 0, 0]

除此之外,您还想指定 WP 的完整路径:

$.ajax({url:"www/pages/result.html",success:function(result){

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-06-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-04
    • 2017-12-01
    相关资源
    最近更新 更多