Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: res.send() and res.render() #238

Open
CrisChr opened this issue Jul 12, 2018 · 2 comments
Open

Question: res.send() and res.render() #238

CrisChr opened this issue Jul 12, 2018 · 2 comments

Comments

@CrisChr
Copy link

CrisChr commented Jul 12, 2018

When I used Ajax post request to submit a form and then res.send({info: info}), but ejs can not get the info object to display. I googled and found most of them would like to use res.render() to refresh the page, but I prefer to use Ajax to implement asynchronous refresh. Anybody can help me or is there any better method?

image

image

image

Thanks

@jsrj
Copy link

jsrj commented Jul 12, 2018

res.send() would usually work, but the two things that stand out is your response is sent under the condition that name and pass are defined and not null. If this condition fails, the router will not send anything, causing the page to appear to be loading until it times out. If this isn’t the issue and you only want to send the info object, you can use res.JSON(info) instead.

@David2913
Copy link

You could pass a callback to done and do the update yourself using jQuery when the response arrives. What do you think?

screen shot 2018-07-26 at 12 00 58 pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants