开发者

tcp handshake terminated by FIN /JSON data not retrieved

Hi I have a website html embadded with java script, the website uploaded into apache tomcat, the website suppose to contact another server and retrieve json data back, this is not happening the packet tracing shows the tcp handshake is terminated by a FIN state the packet send before the FIN state has a checksum incorrect, I'm not sure how to troubleshoot this ? do you think the checksum incorrect is terminating the handshake ? and hwo to avoide that ? the following is my ajax jquery code note: both apache server and the other server are in the same domain. Tha开发者_StackOverflow中文版nk in advance LS

 $(document).ready( function() {
var home_add='http://myhome.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")
                           }                    
                          })   

                          })
})


You seem to be misunderstanding the same-origin policy. The same-origin policy used by XMLHttpRequest, the basis for jQuery's AJAX functionality, is:

  • The two hostnames must be exactly the same (not just part of a higher level domain).
    Example: A web page from careers.stackoverflow.com can access the same domain but not beta.careers.stackoverflow.com, stackoverflow.com, or foo.stackoverflow.com.

  • The two protocols must be exactly the same (http/https).
    Example: A web page from http://stackoverflow.com cannot access https://stackoverflow.com and vice-versa.

  • The two port numbers must be exactly the same (except in Internet Explorer).
    Example: A web page from http://stackoverflow.com cannot access http://stackoverflow.com:8080 and vice-versa in Firefox, Chrome, Safari, or Opera.

You will have to do one of these:

  • Use the Access-Control-Allow-Origin HTTP header in AJAX responses, with the obvious disadvantage of excluding browsers such as IE and older versions of the others that do not support it

  • Use JSONP, which is supported by jQuery though not for synchronous requests (which you should avoid anyway because they can hang the browser)

  • Proxy HTTP requests from the server your web page is served on to the other server

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜