I am having problems using preventDefault. The problem is that this piece of code is working fine (it prevents a click every time, and I get a warning):
$("#vnesi").click(function (e) {
$.post("/VnosPrijavnica/PreveriVnose", $("#kriteriji").serialize(), function (data) {
if (data != "ok")
alert(data);
});
e.preventDefault();
});
But this is not so (nothig happens if the data is either "good" or not):
$("#vnesi").click(function (e) {
$.post("/VnosPrijavnica/PreveriVnose", $("#kriteriji").serialize(), function (data) {
if (data != "ok"){
alert(data);
e.preventDefault();
}
});
});
And one more question. What is the best way to debug javascript in Firefox 4 (or any other browser, but I prefer Firefox 4)?
Update
Thank you for your responses. How can I prevent Default () if I want it to act like in the second code snippet? I want e.preventDefault () to be executed only if the data! = "Ok".
source
share