簡體   English   中英

無法在Windows Phone PhoneGap中發出Ajax請求

[英]Not able to make ajax request in windows phone phonegap

我已經使用phonegap開發了android應用。 現在,我正在嘗試使用該代碼來開發Windows Phone 8應用。 我已經成功設置了Visual Studio Express環境並制作了Cordova模板。 之后,我創建了項目並將我的資產插入該項目。

它向我顯示了我的應用程序UI,並且事件,頁面導航正常運行。 但是它無法建立ajax http連接。 我是否需要在SDK或Project Directory中啟用任何功能。

當我嘗試這樣做時,我會收到“連接失敗”的警報

這是我建立HTTP連接的示例js代碼

             $.ajax({
                 beforeSend: function() {        $.mobile.showPageLoadingMsg("a","Processing !!! Please wait "); },
                 complete:   function() { $.mobile.hidePageLoadingMsg(); },
                 type: 'POST',
                 url:'http://192.168.12.175/Receiver.php', 
                 data: reqObj ,
                 success: function(data){
                 responseString=data;
                 } 
                 error: function(data){
                 //get the status code
             alert('Connectivity Failure');
                 } });

用這個

$.mobile.showPageLoadingMsg("a","Processing !!! Please wait ");

formData = {
    param1: param1
}
$.ajax({
    type: 'POST',
    contentType: 'application/json',
    url: "http://192.168.12.175/Receiver.php",
    dataType: "json",
    data: formData,
    success: function(data) {
        $.mobile.hidePageLoadingMsg();

    },
    error: function(data) {
        alert('Connectivity Failure');
    }
});

在config.xml中添加<feature name="http://api.phonegap.com/1.0/network"/>解決此問題。

這是在生成生成文件時將<Capability Name="ID_CAP_NETWORKING" />到WMAppManifest.xml文件中

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM