【发布时间】:2016-12-25 12:32:59
【问题描述】:
我将以下代码上传到 tomcat 服务器中,该代码假设从其他服务器检索信息,由于某种原因,这没有发生,没有来自其他服务器的回复以下是代码我收到错误功能警报“握手”没有通过”
$(document).ready( function() {
var home_add='http://mywebsite.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("sucessful handshake");
}
});
});
});
我检查了 firebug net 面板,我收到了以下请求标头,但没有响应,也没有 xhr,请给我你的反馈
mywebsite.net:3300
User-AgentMozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101209 CentOS/3.6-2.el5.centos Firefox/3.6.13
Accepttext/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Languageen-us,en;q=0.5
Accept-Encodinggzip,deflate
Accept-CharsetISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive115
Connectionkeep-alive
Originhttp://127.0.0.1:8080
Access-Control-Request-Me...POST
【问题讨论】:
-
contanttype:'text/json'应该是contenttype:'text/json'(e 而不是 a)。 -
最后,记得在适当的地方使用
;。 (你的代码中缺少 3 个)
标签: jquery ajax web-services json firebug