Parse Error Node Js

21 views
Skip to first unread message

Liju Thomas

unread,
Nov 3, 2014, 11:39:48 PM11/3/14
to nod...@googlegroups.com

My code is

I am new to Node.js

var headers ;

var options = {


  host: 'google.com',

  port: 80,

     path: '/game/index.php/',

                            method: 'POST',

headers:headers

  };


function BalanceUpdate(stream ,flag)

{


// console.log("\n BalanceUpdate...................flag"+flag+"\n");

if(stream != 'undefined' &&  stream.balance !='NaN ')

{

 

try

{

// console.log("\n BalanceUpdate yyyyyyyyyyyyyyyyyy "+stream.uid+"&balance="+stream.balance+" stream.id = "+stream.id+"\n");

var str = "uid="+stream.uid+"&balance="+stream.balance;

var len =str.length;



//  //// console.log("VVVVVVVVVVVVVVPlayer Data From Server :" + str);

options.headers ={'Content-length' : len, 'Content-Type': 'application/x-www-form-urlencoded'}                                  

var request = http.request(options, function (response)

{

//  //// console.log("@@@@@@@@@@@@@@@@@@@@Player Data From Server :" + str);

response.on('data', function (str) 

{

// console.log("\nVVVVVVVVVVVVVV BalanceUpdate Data From Server :" + str+"\n");

});

response.on('error', function (err) 

{

// console.log("\n BalanceUpdate Error From Server response :" + err+"\n");

});


response.on('end', function () {

});

});

request.write( str +"\0");

request.on('error', function (err) 

{

// console.log("\n BalanceUpdate Error From Server request:" + err+"\n");  

});

// the data to POST needs to be a string or a buffer

request.end();

}

 

catch (err )

{

// console.log("\n BalanceUpdate Update Error "+err+"\n");

}

}

 

else

{

// console.log("\n BalanceUpdate zzzzzzzzzzzzzzzzzzzzzzz "+stream.uid+"&balance="+stream.balance+" stream.id = "+stream.id+"\n");

}



}



Some times it works , some times not . Please help me
Reply all
Reply to author
Forward
0 new messages