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

Commit ac0137e

Browse files
committed
added exit to formResponse
1 parent f38dc25 commit ac0137e

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

ajax/process_livesearch.php

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
use AjaxLiveSearch\core\Handler;
34

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

32-
try {
33-
// 4. Start looking for the query
34-
$result = json_encode(Handler::getResult(
35-
$_POST['ls_query_id'],
36-
$_POST['ls_query'],
37-
(int) $_POST['ls_current_page'],
38-
(int) $_POST['ls_items_per_page']
39-
));
40-
} catch (\Exception $e) {
41-
$catchedError = $e->getMessage();
42-
}
43-
44-
if (empty($catchedError)) {
45-
// 5. Return the result
46-
Handler::formResponse('success', 'Successful request', $result);
47-
} else {
48-
Handler::formResponse('failed', $catchedError);
49-
}
33+
try {
34+
// 4. Start looking for the query
35+
$result = json_encode(Handler::getResult(
36+
$_POST['ls_query_id'],
37+
$_POST['ls_query'],
38+
(int) $_POST['ls_current_page'],
39+
(int) $_POST['ls_items_per_page']
40+
));
41+
} catch (\Exception $e) {
42+
$caughtError = $e->getMessage();
43+
}
44+
45+
if (empty($caughtError)) {
46+
// 5. Return the result
47+
Handler::formResponse('success', 'Successful request', $result);
48+
} else {
49+
Handler::formResponse('failed', $caughtError);
50+
}

core/Handler.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ public static function formResponse($status, $message, $result = '')
9191
$message = "<tr><td class='{$css_class}'>{$message}</td></tr>";
9292

9393
echo json_encode(array('status' => $status, 'message' => $message, 'result' => $result));
94+
exit;
9495
}
9596

9697
/**

0 commit comments

Comments
 (0)