Tuesday 16 May 2017

res.send equivalent in jquery?

I want a post request and server process the request and send the response back to client. I can achieve this using res.send() in express node js. But i want to know if the same can be achieved in ajax jquery post method .

app.post('/', function(req, res) {

    const assistant = new Assistant({ request: req, response: res });
    //var filter = req.body.result.parameters.Filter;
    //var state = req.body.result.parameters.State;
    var filter = "hi",
        state = "bye";
    // var output = dofunction(filter, state);
    //console.log("Done");
    request('http://localhost:8080/ibi_apps/WFServlet?IBIF_ex=test1/report6&rnd=0.045486010721947', function(error, response, body) {
            //  if (!error && response.statusCode == 200) {
            //    var info = JSON.parse(body);
            /*parseString(body, function(err, result) {
                console.log(result);
                 var info = JSON.parse(result);
               res.send(info);
             });*/
            //  res.send(info);
            // res.send(body);
            //info = (body);
            // console.log(info);
            xml2js.parseString(body, function(err, result) {
                if (err) {
                    console.log(err);
                }
                res.send(JSON.stringify(result));

            });
        })

Here i have sent the result to the client using res.send . How do i achieve this in ajax jquery ?



via Ash

No comments:

Post a Comment