-1

1˚ - Client:

$.ajax({
    type: 'POST',
    data: data,
    url: '/someposturl',
    success: function (data) {
        console.log('success');
        // $('body').html(data); // i don't want it, but if not so, nothing happens (render) 
    }
});

2˚ - Server:

app.get('/criptografar', function (req, res) {
    console.log(req.something);
    res.render('somepage', {
        somevar: withsomevalue
    });
    //-I want this to work like a normal post
});

3˚ - Client -> 'somepage' - not rendered without this in the client:

$('body').html(data); // i don't want it, but if not so, nothing happens (render)

or this

$('html').html(data); // i don't want it, but if not so, nothing happens (render) <- Jade Layout error.
ThiefMaster
  • 310,957
  • 84
  • 592
  • 636
  • 2
    And what is supposed to happen? You are doing ajax call and server responds with data as you can clearly see. Do you understand what ajax is? :) If you want it to work like a normal POST you can for example return URL from server and do `location.href = url;`. – freakish Mar 20 '12 at 15:27
  • Please format your code properly next time; while others are likely to do it quickly it's not nice to let them do something you can easily do, too. – ThiefMaster Mar 20 '12 at 23:46
  • You should use **app.post(** instead of app.get( – Hitesh Chavda Oct 15 '12 at 07:18

1 Answers1

-1

Because you call it from $.ajax from client side. It works good if you call it from server side

To make a page call a URL from server side, you should add this to your form

form(role="form" method="POST")

Please refer to this question. Express.js Won't Render in Post Action

Community
  • 1
  • 1
Aminah Nuraini
  • 18,120
  • 8
  • 90
  • 108