0

I'm trying to call a client-side function from within my server side file, my server.js is something like this:

var express = require('express');
const errjs = require('./public/js/popup.js');

app.post('/signin', function(req, res, next) {
  passport.authenticate('local', function(err, user, info) {
    if (err) return next(err)
    if (!user) {
    errjs.popuperror("wrong");
      return res.redirect('/signin')
}

My popup.js code is also something like this:

function popuperror(type, message)
{
    if (type == "wrong")
    {
        $(".login-form-container .btn-line").css({backgroundColor: "#EF5350"});
        $("#loginMessage").html("Invalid Username or Password");
        $("#loginMessage").animate({opacity: 1}, 100);
        return (1);
    }
module.exports.popuperror = errjs;

Is there a way to do that even with using JQuery on the front-end js?

Hi There
  • 167
  • 1
  • 5
  • 12
  • That’s not going to work. You should return a message indicating failure and the client should run run the pop up function. – Mark Dec 15 '18 at 17:38
  • @MarkMeyer Could you give me an example to use? I'm not sure I understand exactly how to do that. – Hi There Dec 15 '18 at 17:42

0 Answers0