Thank you all,

Martin I looked at express-messages but I don't know if it works with 
JQuery Mobile? as I 'm using JQuery Mobile. Richard all I'm trying to do is 
to send JQuery Error Message in case of error. I don't wont to redirect the 
user Just send Ajax response with the message.

Thanks,
Feras

On Tuesday, April 24, 2012 2:37:45 PM UTC+3, Martin Wawrusch wrote:
>
> Look into this module here.  
> https://github.com/visionmedia/express-messages  and this one if you use 
> bootstrap:  https://github.com/JasonGiedymin/express-messages-bootstrap 
>
> cheers
> Martin
>
> On Tue, Apr 24, 2012 at 4:31 AM, Richard Marr wrote:
>
>> Not sure what the main problem is as I'm not familiar with the tools and 
>> don't have enough info to guess, but there are a couple of style points 
>> that I'd make:
>>  
>>    - You seem to have a load of jQuery code in your Express response. 
>>    I'd recommend staying well away from that approach for most applications 
>> as 
>>    it's harder to control in terms of separation of concerns, encapsulation, 
>>    caching, etc. 
>>    - Your function looks like it will return either an HTML fragment or 
>>    an HTTP redirect, which to me is a confusing combination, do you mean to 
>>    redirect the entire browser or just tell the XHR object to fetch a 
>>    different fragment from "/account"? 
>>
>> Also, if you're stuck it's helpful to throw a few console.log() 
>> statements in there and make sure what's happening matches your 
>> expectations.
>>
>>
>>
>> On 24 April 2012 08:54, Feras Odeh wrote:
>>
>>> I want to show error messages for users in cases of wrong credentials. 
>>> How could I do that in Express JS? I tried the following code but it 
>>> doesn't work:
>>>
>>> app.get('/', function(req, res, next) {
>>>         passport.authenticate('local', function(err, user, info) {
>>>         if (err) { return next(err) }
>>>         if (!user) { return res.send($( "<div class='ui-loader 
>>> ui-overlay-shadow ui-body-e ui-corner-all'><h1>YOUR MESSAGE</h1></div>" )
>>>         .css({ "display": "block", "opacity": 0.96, "top": 
>>> $(window).scrollTop() + 100 })
>>>         .appendTo( $.mobile.pageContainer )
>>>         .delay( 800 )
>>>         .fadeOut( 400, function() {
>>>         $( this ).remove();
>>>         })
>>>         );  }
>>>         req.logIn(user, function(err) {
>>>         if (err) { return next(err); }
>>>         return res.redirect('/account');
>>>         });
>>>         })(req, res, next);
>>>     });
>>>
>>> What is the problem with this?
>>>
>>> Thanks,
>>>
>>> Feras
>>>
>>> -- 
>>> 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
>>>
>>
>>
>>
>> -- 
>> Richard Marr
>>  
>> -- 
>> 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
>>
>
>
>
>
>
>
>
>  

-- 
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

Reply via email to