Reputation: 261
Hello,
I'm having this issue with jQuery where I get the error Unexpected Token Else. However, when I remove the statement ending Semicolons on certain points, this will stil throw the error. I'm fairly new to jQuery, so the question is simple; Is the following code possibile or is it really strange? Why is it always throwing te Unexpected Token Else?
I've checked some other Questions about this problem, however, none of them contained a Solution for me. I've tried some solutions, they don't fix the issue.
Thanks,
$('#question').keyup(function(){
if($(this).val().length > 5)
$('#noanswer').show();
var suchbegriff = $('#question').val();
$.ajax({
url: './app/tpl/skins/magical/includes/searchsupport.php',
data: {
question: suchbegriff
},
method: 'GET'
}).done(function(data) {
$("#searchresults").html(data).show();
}).fail(function() {
alert("Error");
});
else
$('#noanswer').hide();
});
Upvotes: 0
Views: 95
Reputation: 19372
Fix:
$('#question').keyup(function(){
if($(this).val().length > 5) {
$('#noanswer').show();
// etc stuff...
}
else {
$('#noanswer').hide();
}
});
or:
$('#question').keyup(function(){
$('#noanswer').hide();
if($(this).val().length > 5) {
$('#noanswer').show();
// etc stuff...
}
});
Upvotes: 0