Hi Srividhya, Two things I noticed:
1) you're call to app.listen() needs to be outside your app.get method. Based on the snippet above, it'll only bind to port 8889 once a request is received (so will never happen). 2) you need to replace 'custom_header' with 'emp_value' if that's the specific header you want. When I made these changes (see https://gist.github.com/ccare/5583700) it started working. Hope that helps, Charles On 15 May 2013 13:11, Sri Vidhya <[email protected]> wrote: > Hi All, > This is srividhya working on nodeJS. I have one query regarding getting > the header information from the ajax request(on client side html page) to > the server side code on NodeJS. Here in the below code on headers section am > having "emp_value" as "XYZ", so i want to get the "XYZ" on server side > through NodeJS. With this i will send the ajax request on html page and the > server side code which i have used to get the header information. But it is > not giving the header information, also if am using the header:{} on ajax > request with post method , it wont call the nodeJS serverside code. Anyone > tell how to get the header value which is coming from the header request. > > > > client.html: > $.ajax({ > // url:'http://10.163.14.52:8888/all', > url:'http://IPaddress:port/getTaluk/', > type:'POST', > datatype:'json', > data:inputVal, > headers : { > 'emp_value':'XYZ', > > 'signature':hash, > 'timestamp':t > }, > complete:function(){ > alert(":"+data); > > > } > }); > > server side: > > var express = require('express') > var app = express.createServer(); > app.use(express.bodyParser()); > app.get('/getTaluk', function(request, response){ > console.log("eneters :::"); > console.log("emp_value:"+request.headers['custom_header']); //code used to > get header information > app.listen(8889); > }); > console.log("Server has started."); > > > > On Tue, May 14, 2013 at 6:04 PM, Charles Care <[email protected]> wrote: >> >> Hi Sri, >> >> You'll probably need to share a bit more server-side code than just the >> console.log() so that we can see what you're trying to do. >> >> Thanks, >> >> Charles >> >> >> On Tuesday, May 14, 2013 1:08:48 PM UTC+1, Srividhya wrote: >>> >>> HI am sending the header information (like below)to node.js on the server >>> side, but it is not working. >>> How to pass the header information to server from client. and how to get >>> on the server side . >>> Pls if anyone knows... let me know >>> >>> this is the ajax request call fron client html page: >>> >>> client.html: >>> >>> $.ajax({ >>> // url:'http://10.163.14.52:8888/all', >>> url:'http://IPaddress:port/getTaluk/', >>> type:'POST', >>> datatype:'json', >>> data:inputVal, >>> headers : { >>> 'emp_value':s, >>> 'signature':hash, >>> 'timestamp':t >>> }, >>> complete:function(){ >>> alert(":"+data); >>> >>> >>> } >>> }); >>> >>> on the server side am getting like this using nodejs: >>> >>> console.log("emp_value:"+req.headers['emp_value']); >>> but i can't able to get it. >>> >>> -- >>> Thanks, >>> N. Srividhya. >> >> -- >> -- >> Job Board: http://jobs.nodejs.org/ >> Posting guidelines: >> 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 post to this group, send email to [email protected] >> To unsubscribe from this group, send email to >> [email protected] >> For more options, visit this group at >> http://groups.google.com/group/nodejs?hl=en?hl=en >> >> --- >> 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 [email protected]. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> > > > > > -- > Thanks, > N. Srividhya. > > -- > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > 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 post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en > > --- > 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 [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > > -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: 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 post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- 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 [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
