用于PhoneGap的Ajax

时间:2014-04-25 10:20:34

标签: javascript android jquery ajax cordova

我想从页面上的菜单的单独文件中加载内容(每个菜单选项都有单独的内容文件.txt)。我只想改变内容区域。我写了一个声明xmlHttp变量的代码。这个变量是一个浏览器变量,因此它能够为我提取数据吗?

我正在设计一个用于cordova的Android应用程序。

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">

<html>
<head>
    <title></title>
</head>

<body>
    <div class="ui-content" data-role="main">
        <div id="A4FullspecsSideMenudiv">
            <ul data-icon="arrow-r" data-role="listview" id=
            "A4FullspecsSideMenu">
                <li><a class="ui-state-persist" href="#" id="A4Design" name=
                "A4Design" onclick="contentfetch()">Design</a></li>

                <li><a class="ui-state-persist" href="#">Technical
                Data</a></li>

                <li><a class="ui-state-persist" href="#">Efficiency</a></li>

                <li><a class="ui-state-persist" href="#">Equipments</a></li>
            </ul>
        </div>

        <div id="AudiA4Content">
            <h3>Text about Design</h3><br>

            <p>Text about DesignText about DesignText about DesignText about
            DesignTextText about DesignText about DesignText about DesignText
            about DesignText about DesignText about DesignText about DesignText
            about DesignText about DesignText about DesignText about DesignText
            about DesignText about DesignText about DesignText about Design<br>
            <br>
            Text about DesignText about DesignText about DesignText about
            DesignTextText about DesignText about DesignText about DesignText
            about DesignText about DesignText about DesignText about DesignText
            about DesignText about DesignText about DesignText about DesignText
            about DesignText about DesignText about DesignText about Design<br>
            <br>
            Text about DesignText about DesignText about DesignText about
            DesignTextText about DesignText about DesignText about DesignText
            about DesignText about DesignText about DesignText about DesignText
            about DesignText about DesignText about DesignText about DesignText
            about DesignText about DesignText about DesignText about Design<br>
            <br></p>
        </div>
    </div>
</body>
</html>

此A4内容的文本将被更改。我做了一些阅读并使text.html中的4个标签和单独的文本。

function contentfetch() {
    var txt = $("#A4div1").load("A4Specs.html");
    $("#A4Design").click(function() {
        $("AudiA4Content").val(txt);
    });
}

上执行此脚本
 <li><a href="#" onclick="contentfetch()" id="A4Design" class="ui-state-persist">Design</a></li>

1 个答案:

答案 0 :(得分:0)

没错,

使用$(“AudiA4Content”)。load(“MyHtml.html #thedivwithInfo”);