使用JSONP的Phonegap Android无效

时间:2016-01-05 21:28:44

标签: javascript android cordova jsonp phonegap-build

我正在使用JSONP制作适用于Android的Phonegap应用,但却没有使用APK。 有些代码是西班牙语,但没有区别。

<!DOCTYPE html>
<html>
<head>
    <script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
    <script src="jquery.min.js"></script>
    <script src="jquery.jsonp-2.4.0.min.js"></script>
<script>
$(document).ready(function(){
    var output = $('#output');

    $.ajax({
        url: 'http://www.laprepie.com/form/sql/1.php',
        dataType: 'jsonp',
        jsonp: 'jsoncallback',
        timeout: 5000,
        success: function(data, status){
            $.each(data, function(i,item){ 
                var landmark = item.ID_Sucursal+item.Numero+item.Direccion;
                output.append(landmark);
            });
        },
        error: function(){
            output.text('There was an error loading the data.');
        }
    });
});
</script>
</head>
<body>
<ul id="output"></ul>
</body>
</html>

但是当我执行apk(我使用来自phonegap build.phonegap.com的在线APK Builder)然后我在手机上安装时,这根本不起作用。

在我的笔记本电脑上工作得很好。

真的需要帮助,让我发疯! 谢谢!

1 个答案:

答案 0 :(得分:0)

在一个懒散的夜晚试图了解我的代码出了什么问题之后。

我使用了这个Tutorail http://www.gajotres.net/building-a-native-mobile-app-with-phonegap-and-jquery-mobile-1-4/

使用CLI系统编译apk并运行!

不知道为什么!