I am trying to make a link work if a condition is true for which I am sending a jQuery.get()
and checking if the link should jump to the next page or not.
I am using the following code for it:
<script type="text/javascript">
var jq = jQuery.noConflict();
function checkDoubleSubmit() {
jq(function() {
jq.get("/checkDoubleSubmit",
function(data) {
if(data == null) {
return true;
}
else {
alert("double submit is not allowed");
return false;
}
}
);
});
}
</script>
<a href="<c:url value="/submit" />" onclick="return checkDoubleSubmit();">check double submit</a>
Even if data
is not null
the page is jumping to the next page.
Could someone help me understand what am I doing wrong here?
Thanks.