javascript - Sending alert message if user not logged in -


What is the best way to send a warning message to a user if he needs to login, but at the same time Avoid calls? Send me the & lt; A href = "#" id = "vote" & gt; A code can be triggered, which will trigger an Ajax function based on the click. I was thinking that I would check on the server side if a user is logged in and changes it: & lt; A href = "#" class = "not-logged-in" & gt; If this is clicked it will inform them that they need to enter. The problem is that there may be some CSS style for my #vote. If instead I want it to be and lt; A href = "#" id = "vote" class = "not-logged-in" & gt; , then it will trigger both AJAX calls and alerts, so I have to wrap the Ajax call around with a check, to see that the log-in class is not present, but it seems Is that the AJAX call for all my click functions, or do I call the original ID and set the style like #parentId {}? Or are there any better ways? I'm not sure what people usually do, so look at some opinions. Thanks!

How about:

HTML:

& lt; Body class = "not-logged-in" & gt; - or - & lt; Body class = "log-in" & gt; & Lt; A href = "/ vote / 13" square = "vote" & gt; Vote! & Lt; / A & gt;

jQuery:

  $ ('body.logged-in .vote'). Click (function () {$ (this) .append ($ .get ($ (this) .attr ('href')); return false;});  
< / Html>

Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -