0

webworks、jquery バージョン 1.6.4、および PhoneGap で開発されたアプリケーションで、$.post を使用すると問題が発生します。他の同様の質問は Ajax を使用して解決されますが、私の場合はそうではありませんでした。

彼は私のコードの一部を追加して、解決策を見つけようとしました。

索引.html

<!DOCTYPE HTML>
<html>
<head>
<title>Prueba</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="css/estilo.css" />
<link rel="stylesheet" type="text/css" href="css/sunny/jquery-ui-1.8.21.custom.css" />
<script type="text/javascript" src="js/json2.js"></script>
<script type="text/javascript" src="js/cordova-1.9.0.js"></script>
<script type="text/javascript" src="js/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.21.custom.min.js"></script>
<script type="text/javascript">
    // process the confirmation dialog result
    function onConfirmaSalir(button) {
        if (button == 2) {
            // si
            navigator.app.exitApp();
        }
    }

    // Show a custom confirmation dialog
    //
    function showConfirm() {
        navigator.notification.confirm(
            'Desea abandonar la aplicaci�n?',  // message
            onConfirmaSalir, // callback to invoke with index of button pressed
            'Salir',         // title
            'No,Si'          // buttonLabels
        );
    }

    // Handle the back button
    function onBackKeyDown() {
       showConfirm();
    } 

    // alert dialog dismissed
    function alertConexion() {
        // do something
    }

    function showErrorConexion() {
        navigator.notification.alert(
            'Sin conexion, intente nuevamente',  // message
            alertConexion,         // callback
            'Error',            // title
            'Ok'                  // buttonName
        );
    }

    function checkConnection() {
            var networkState = navigator.network.connection.type;
            if (networkState == Connection.NONE) {
                return false;
            } else {
                return true;
            }
    }

    function cargarTabla(inicio) {
        $.post("http://sitio.com/", 
                { 
                },
                function(datos) {
                    $('#tabla').html('<article>'+datos+'</article>');
                }
        );
    }

     // PhoneGap is ready
    function onDeviceReady() {
        document.addEventListener("backbutton", onBackKeyDown, false);

        if (checkConnection()) {
            cargarTabla(1);
        } else {
            showErrorConexion();
        }
    }

    // phonegap
    function onBodyLoad()
    {
        // Wait for PhoneGap to load
        document.addEventListener("deviceready", onDeviceReady, false);
    } 
</script>
</head>
<body onload="onBodyLoad();">

<header>
        <h1>Prueba</h1>
</header>
<section>
    <article>
        <p>Hola!</p>
    </article>
</section>
<section id="tabla">
    <article>
            <p>Cargando...</p>
    </article>
</section>
</body>
</html>

css、ext (.jar codova を含む)、img、config.xml、index.html、plugins.xml を含む zip ファイルを生成します。

パッケージ化: bbwp path_zip -o path_out

ファイルを正常に生成しますが、実行時に、html の「タブラ」セクションの内容を変更しません。

PhoneGap と webworks で jQuery Post を使用するにはどうすればよいですか? 同じコードが Android でも機能します。ありがとう。

4

1 に答える 1

0

外部リソースにアクセスするための構成ファイルで要素を指定していないようです。

config.xml ファイルに以下を含めます。<access uri="http://sitio.com" subdomains="true"/>

詳細については、アクセス要素のドキュメントを確認してください: https://developer.blackberry.com/html5/documentation/access_element_834677_11.html

于 2012-07-26T17:12:56.100 に答える