简体   繁体   English

带有JSONP的Phonegap Android无法正常工作

[英]Phonegap Android with JSONP Not Working

I'm making a Phonegap app for Android with JSONP but is not working on the APK. 我正在使用JSONP开发适用于Android的Phonegap应用,但无法在APK上运行。 Some of the code is in Spanish but makes no difference. 一些代码是西班牙语,但没有区别。

<!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>

But when I do the apk (I'm using online APK Builder from phonegap build.phonegap.com ) and then I install on my phone, this does not work at all. 但是,当我执行apk(我正在使用来自phonegap build.phonegap.com的在线APK Builder),然后将其安装在手机上时,这根本不起作用。

On my Laptop works wonderful. 在我的笔记本电脑上,效果很好。

Really Need help with this, is making me crazy! 真的需要帮助,这让我发疯了! thanks! 谢谢!

After a loooong night trying to understand what was wrong with my code. 经过漫长的夜晚,试图了解我的代码出了什么问题。

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

And compile the apk with the CLI system and worked! 并使用CLI系统编译apk并成功!

No idea Why! 不知道为什么!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM