If its on the same server, use JSON as the data type.

And express gives you a method for returning json


var objToReturn = {} 



res.json(objToReturn)

—
Sent from Mailbox for iPhone

On Mon, Jun 3, 2013 at 12:59 PM, Sri Vidhya <[email protected]> wrote:

> How to call nodejs service through ajax request from a html file on a
> client side. I wrote like this. But it is not working
> sample.html
> ***********
> ..........
> ..............
> ..........
> ........
>  $.ajax({
>    url:'http://10.163.14.52:9999/login/',
>    type:'GET',
>    dataType: "jsonp",
>    headers : {"empname":"sri"},
>   contentType:"application/json",
>   success:function(data){
>   ...
>   ...
>   ...
>  error: function (jqXHR, textStatus, errorThrown) {
>                             //your error handle goes here
>                             alert("Errorrrrr:"+JSON.stringify(jqXHR));
>                         }
>    })
> ..........
> ..............
> ..........
> ........
> I want to get the empname value in the nodejs service through ajax request.
> on NodeJS side i used like this to get the header value:
> var https = require('http');
> var pg = require('pg');
> var express = require('express')
> var app = express.createServer();
> app.get('/login', function(request, response){
> console.log("*****starts*******");
> //console.log("header======>"+JSON.parse(request.header('empname')));
> .......
> ;;;;;;
> ........
> .....
> });
> app.listen(9999);
> console.log("Server has started.");
> But it is not working...Please anybody tell how to solve this.
> -- 
> 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.


Reply via email to