Very basic error handling

develop
Sven Slootweg 12 years ago
parent 6ec1a2d90b
commit dd4c62bc4e

@ -36,6 +36,8 @@ else
array_unshift($db_query_arguments, '');
unset($db_query_arguments[0]);
try
{
$results_topics = Topic::CreateFromQuery("SELECT * FROM topics WHERE {$db_query}", $db_query_arguments);
$return_objects = array();
@ -47,3 +49,8 @@ else
$sPageContents = json_encode($return_objects);
}
catch (NotFoundException $e)
{
$sPageContents = json_encode(array("error" => "No results found for the specified query.", "query" => $query));
}
}

@ -136,3 +136,9 @@ a.title
{
content: ")";
}
.error
{
margin: 8px 16px;
font-size: 19px;
}

@ -11,7 +11,7 @@
/*$("input").val("data");
runSearch();*/
$("input").keypress(function(){
$("input").keyup(function(){
if(typeof search_timeout !== "null")
{
clearTimeout(search_timeout);
@ -27,10 +27,14 @@
$(".spinner").show();
var query = $("input#query").val();
if(query.length >= 3)
{
$.post("/api/search", {q: query}, function(response){
$(".spinner").hide();
$(".results").html("");
if(typeof response.error == "undefined")
{
for(i in response)
{
if(response[i].items.length > 0)
@ -56,10 +60,21 @@
result_wrapper.appendTo(".results");
}
}
}
else
{
$(".results").html("<div class='error'>No results.</div>");
}
setHandlers();
}, "json");
}
else
{
$(".spinner").hide();
$(".results").html("<div class='error'>Enter at least 3 characters.</div>");
}
}
function setHandlers()
{

Loading…
Cancel
Save