- $(document).ready(function() {
$('.error,.success').hide();
var ajaxComplete=1;
$("#send").click(function (){
$('.error,.success').hide("slow");
if (ajaxComplete==1){
$.ajax({
ajaxComplete=0;
url: 'add.php?lnk='+escape($('[name=lnk]').val())+'&name='+escape($('[name=name]').val())+'&img='+escape($('[name=img]').val()),
success: function(newContent){
$(".success").html("New Book mark created");
$(".sampleList").append(newContent);
$('.success').show("slow");
$('[name=name],[name=lnk],[name=img]').html('');
ajaxComplete=1;
}
});
}
});
});
When I took away ajaxComplete (and made the if condition automaically true) then the the javascript didn't have errors.
Why can't I use variables in jQuery like this?