手机间隙服务器连接教程不工作

时间:2014-12-13 10:42:30

标签: javascript jquery cordova

我正在学习本教程:

但是当我按下按钮时,请求没有发送 这是我的代码 当检查控制台时我得到了这个

enter image description here

它是我的功能“连接未定义”

<html>
    <head>
        <meta charset="utf-8" />
        <meta name="format-detection" content="telephone=no" />
        <meta name="msapplication-tap-highlight" content="no" />
        <!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
        <link rel="stylesheet" type="text/css" href="css/index.css" />
        <link href="jQueryMobile/jquery.mobile-1.4.5.min.css" rel="stylesheet" type="text/css" />
        <script src="js/jquery.js" type="text/javascript"></script>
        <script src="jQueryMobile/jquery.mobile-1.4.5.min.js" type="text/javascript"></script>
        <title>Taha king</title>


        <script charset="utf&minus;8" type="text/javascript">
            function connect(e){
                alert("mmmmmmmmmmmm");
                    var term= {button:e};
                    $.ajax({ 
                    url:'http://www.indiageeks.in/tutorials/reply.php',
                    type:'POST',
                    data:term,
                    dataType:'json',
                    error:function(jqXHR,text_status,strError){
                        alert(“no connection”);
                    },
                    timeout:60000,
                    success:function(data){
                        $("#result").html("");
                        for(var i in data){
                        $("#result").append("<li>"+data[i]+"</li>");
                    }
                }
               });}
    </script>

    </head>
    <body>

        <div data-role="header">

         <h1>Your resource app</h1>

        </div>

        <div dara-role="content"> 

                       <center><b>Bikes or Cars</b></center>
        <center><input onclick="connect(this.value)" type="button" value="cars" /></center>
        <center><input onclick="connect(this.value)" type="button" value="bikes" /></center>
        <center><b>Results</b></center>
        <ul id="result"></ul>

        </div>

         <div dara-role="footer">   

            <h4>&copy; carsRent.ps</h4>

        </div> 


      <!--  <script type="text/javascript" src="cordova.js"></script>-->
        <script type="text/javascript" src="js/index.js"></script>
        <script type="text/javascript">
            app.initialize();
        </script>


    </body>
</html>

2 个答案:

答案 0 :(得分:0)

尝试删除此内容:

charset="utf&minus;8"
来自脚本标记的

。 如果你想要utf-8编码,那么你就不需要了:

<meta charset="utf-8">

答案 1 :(得分:0)

connect()功能不存在。你忘了插入它。请再次重新检查。