2010-12-20 96 views
0

我有以下功能它假設與另一臺服務器交談檢索json數據並顯示它的問題是該函數甚至沒有啓動一個查詢我是我在做什麼w??該代碼被上傳到Apache Tomcat服務器,我使用Wireshark的用於跟蹤和這裏有沒有HTTP端口上的代碼是jquery/ajax json數據功能不工作

$(document).ready(function() { 
var home_add='http://wcf.net:3300/gateway'; 
$('#handshake').click(function(){ 
alert(" sending json data"); 
function handshake(){  /*testing the function */ 
         var data_send = { 
          "supportedConnectionTypes": "long-polling", 
          "channel": "/meta/handshake", 
          "version": "1:0" 
          }; 
         $.ajax({     /* start ajax function to send data */ 
          url:home_add, 
          type:'POST', 
          datatype:'json', 
          contanttype:'text/json', 
          async: false, 
          error:function(){ alert("handshake didn't go through")}, /* call disconnect function */ 
          data:JSON.stringify(data_send), 
          success:function(data){ 
          $("p").append(data+"<br/>"); 
          alert("successful handshake") 
          }      
          }) 

          } 
})}) 

預先感謝您的反饋 熔岩

回答

0

ü不來電握手功能...

$(document).ready(function() { 
var home_add = 'http://wcf.net:3300/gateway'; 
$('#handshake').click(function() { 
    alert(" sending json data"); 
    $.ajax({     /* start ajax function to send data */ 
     url: home_add, 
     type: 'POST', 
     datatype: 'json', 
     contanttype: 'text/json', 
     async: false, 
     error: function() { alert("handshake didn't go through") }, /* call disconnect function */ 
     data: { 
      "supportedConnectionTypes": "long-polling", 
      "channel": "/meta/handshake", 
      "version": "1:0" 
     }, 
     success: function (data) { 
      $("p").append(data + "<br/>"); 
      alert("successful handshake") 
     } 
    }); 

}); 

});

+0

你好,謝謝你的回覆我跟着你的反饋,但它仍然不工作:( – Lava 2010-12-20 19:19:57

0

如果您正在使用Internet Explorer你在添加以下代碼到你的JSP頁面中頭部分

<script src="https://github.com/douglascrockford/JSON-js/blob/master/json2.js" /> 

試試這一個,檢查,可能是它會奏效。