Often, when we encounter a situation when the link has to be followed with some condition check in server, we could skip the form and use the simple
var _this = this; . Now we could use this operator to access the js variable inside the ajax function.
a tag will navigate the link by default so in order to block it we will use the
onClick event. This event will fire and the link will be navigated if the response is true and our function returns either true or false based on the server response. And that’s that. Simple huh!! The code should be self explanatory. But just in case you need my help, you know where to find me else please drop a comment 🙂