Parse Error Node js

77 views
Skip to first unread message

Liju Thomas

unread,
Nov 3, 2014, 11:11:27 PM11/3/14
to nod...@googlegroups.com
I am new to Node js

My code is 

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 time it works ,some times not. Please help me

Christopher Rust

unread,
Nov 4, 2014, 3:59:41 PM11/4/14
to nod...@googlegroups.com

What sort of errors do you get?

Is google.com/game/index.php actually expected to exist?

--
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
To post to this group, send email to nod...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/4ba319c2-67ec-4501-acd3-5fe344c517c3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages