Hi I'm trying to creating client side scripting using jquery/ajax I have to start a 1- handshake with the server then 2-connect then 3- start a longpolling channel. Json is the data format for those 3 steps, now can somebody tell me if this is the right way to do it

what Iam doing is I'm starting the handshake get the client ID then inside the ajax success I'm inserting the user ID and having the connect function same thing with the connect and longpolling

I'm also not sure about json parsing I can't find a useful example for that


$('#handshake').click(function(){
var data_send = {
"supportedConnectionTypes": "long-polling",
"channel": "/meta/handshake",
"version": "1:0"}
$.Ajax({ /* start ajax function to senddata*/
url:uri_home
type:'post';
datatype:'json';
contanttype:'text/json';
error:function(){ alert("handshake didn't go through")};
data:JSON.stringify(data_send);

success:function(data){
var obj=JSON.parse("clientId")// get the clientID from the returned json server data//
var dat={
"connectionType":"long-polling",
"channel":"/meta/connect"}
var data_send1=dat+obj

$.Ajax({
url:uri_home;
type:'post';
datatype:'json';
contanttype:'text/json';
error:function(data){ alert(" restart handshake/ connect didn't go through");
data:JSON.stringify(data_send1)
success:function(data){
var data_send2{ /*data sent */
"channel":"long-polling",
"clientID:"obj"}
$.Ajax({

url:uri_home;
type:'post';
datatype:'json';
contanttype:'text/json';
data=JSON.stringify(data_send2)
success:function(data){
alert"longpolling")}
error:function(){alert("long polling error")};

})});