1

I have a website uploaded into apache tomcat. The code is shown below this website suppose to retrieve json data from other server. For some reason the other server is not responding as I'm getting the error message "handshake didn't go through". Firebug net panel shows no response header also the apache and the other server are on the same domain. Can you please provide a feedback or clue on how to troubleshoot this? Is there anything with ajax cause it seems it is not sending.

Java script code:

$(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',
                contenttype:'text/json',
                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 time line shows DNS lookup, connecting and waiting there is no sending nor receiving. The request header is the following but there is no response.

Hostmywebsite.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

1 Answer 1

1

Are you making an ajax call to a domain other than your domain (i.e. the page is from mydomain.com but the ajax call is to theirdomain.com?) If so, this isn't allowed with straight json, but you can look into jsonp (json with padding)

Sign up to request clarification or add additional context in comments.

3 Comments

Something else I noticed. I don't know if this just from your example or if this is the actual code, but dataType and contentType are not cased correctly in what you have above. One of my biggest dislikes of javascript is that it is both interpreted and case-sensitive. Many hours have been lost because of that.
Hi Brian thanks for the reply I did what you told me but still the same thing :(
Is the page the ajax coming from served up on a standard port (80 or 443)? Is it possible to have the ajax call go to a standard port? Just wondering if there is some weird issue with using a non-standard port. Also, have you tried this in other browsers, do they work?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.