2014-12-13 70 views
0

我非常新的JavaScript我正在跟隨着這個toturial電話差距服務器連接toturial不工作

http://www.indiageeks.in/phonegap-jquery-ajax-example-jsonjavascript-object-notation-response/

但是當我按要求不發送 的按鈕,這是我的代碼 當檢查控制檯我得到這個

enter image description here

它iays泰德我的功能 「連接不defiend」

<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> 
+0

什麼是錯誤等? – 2014-12-13 10:55:01

+0

@ A.B Uncaught ReferenceError:未定義連接 – mohammad 2014-12-13 11:09:11

+0

@ A.B還將錯誤添加到問題 – mohammad 2014-12-13 11:15:25

回答

0

嘗試刪除此:

charset="utf&minus;8" 

從腳本標籤。 如果你想UTF-8編碼沒有必要,既然你使用:

<meta charset="utf-8"> 
+0

它沒有工作 – mohammad 2014-12-13 12:42:30

0

connect()功能是不存在的。你忘了插入它。請重新檢查。

相關問題