ravin
02-05-2010, 10:04 AM
Message: 'length' is null or not an object
Line: 16
Char: 5
Code: 0
This is very frustrating!! Ive tried any IF ELSE but nothing works.
This is a Jquery search engine code.
If I type a word that exists in the database if(data.length >= 0) its OK
But if the word does not exist the above line freaks out with a length error.
function lookup(inputString) {
if(inputString.length <2) {
// Hide the suggestion box.
$('#suggestions').hide();
} else {
$.post("rpc.php", {queryString: ""+inputString+""}, function(data){
if(data.length >= 0) {
$('#suggestions').show();
$('#autoSuggestionsList').html(data);
}
});
}
} // lookup
function fill(thisValue) {
$('#inputString').val(thisValue);
setTimeout("$('#suggestions').hide();", 200);
}
How can i overcome this? I want the Jquery to reply "No results" when there is no data from the database.
Line: 16
Char: 5
Code: 0
This is very frustrating!! Ive tried any IF ELSE but nothing works.
This is a Jquery search engine code.
If I type a word that exists in the database if(data.length >= 0) its OK
But if the word does not exist the above line freaks out with a length error.
function lookup(inputString) {
if(inputString.length <2) {
// Hide the suggestion box.
$('#suggestions').hide();
} else {
$.post("rpc.php", {queryString: ""+inputString+""}, function(data){
if(data.length >= 0) {
$('#suggestions').show();
$('#autoSuggestionsList').html(data);
}
});
}
} // lookup
function fill(thisValue) {
$('#inputString').val(thisValue);
setTimeout("$('#suggestions').hide();", 200);
}
How can i overcome this? I want the Jquery to reply "No results" when there is no data from the database.