Skip to content
This repository has been archived by the owner on Jul 17, 2022. It is now read-only.

Commit

Permalink
added exit to formResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
iranianpep committed May 7, 2016
1 parent f38dc25 commit ac0137e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
37 changes: 19 additions & 18 deletions ajax/process_livesearch.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

use AjaxLiveSearch\core\Handler;

header('Access-Control-Allow-Origin: http://ajaxlivesearch.com');
Expand Down Expand Up @@ -29,21 +30,21 @@
Handler::formResponse('failed', 'Error: Please refresh the page. It seems that your session is expired.');
}

try {
// 4. Start looking for the query
$result = json_encode(Handler::getResult(
$_POST['ls_query_id'],
$_POST['ls_query'],
(int) $_POST['ls_current_page'],
(int) $_POST['ls_items_per_page']
));
} catch (\Exception $e) {
$catchedError = $e->getMessage();
}

if (empty($catchedError)) {
// 5. Return the result
Handler::formResponse('success', 'Successful request', $result);
} else {
Handler::formResponse('failed', $catchedError);
}
try {
// 4. Start looking for the query
$result = json_encode(Handler::getResult(
$_POST['ls_query_id'],
$_POST['ls_query'],
(int) $_POST['ls_current_page'],
(int) $_POST['ls_items_per_page']
));
} catch (\Exception $e) {
$caughtError = $e->getMessage();
}

if (empty($caughtError)) {
// 5. Return the result
Handler::formResponse('success', 'Successful request', $result);
} else {
Handler::formResponse('failed', $caughtError);
}
1 change: 1 addition & 0 deletions core/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public static function formResponse($status, $message, $result = '')
$message = "<tr><td class='{$css_class}'>{$message}</td></tr>";

echo json_encode(array('status' => $status, 'message' => $message, 'result' => $result));
exit;
}

/**
Expand Down

0 comments on commit ac0137e

Please sign in to comment.