What would be the best way to send an alert message to the user if it requires them to login, but at the same time avoid an ajax call? I might have code like <a href="#" id="vote"> which would trigger an ajax function based on the click. I was thinking I would check on the server side if a user is logged in and replace it with:
<a href="#" class="not-logged-in">. If that is clicked then it will alert them that they need to log in. The problem is that I might have some css styles for the #vote. If instead I make it <a href="#" id="vote" class="not-logged-in"> it would trigger both the ajax call and alert, so I’d have to wrap the ajax call around with a check to see that the not-loggin-in class does not exist, but it seems a bit tedious to do that for all my click functions that have ajax calls. Or either I would call the parent id and set the style like #parentId a{}? Or is there any better methods? I’m not sure what people usually do, so looking for some opinions. Thanks!
What would be the best way to send an alert message to the user
Share
How about this:
The HTML:
The jQuery: