Added javascript code to add a result in the background without refreshing the page
This commit is contained in:
@ -24,14 +24,21 @@ class ResultController extends Controller {
|
||||
|
||||
$result->save();
|
||||
|
||||
// redirect the user back to the home page
|
||||
$routeContext = RouteContext::fromRequest($request);
|
||||
$routeParser = $routeContext->getRouteParser();
|
||||
return $response
|
||||
->withHeader('Location', $routeParser->urlFor('test.view', [
|
||||
'test_id' => $result->test_id
|
||||
]))
|
||||
->withStatus(302);
|
||||
if (!isset($params['redirect']) || $params['redirect'])
|
||||
// redirect the user back to the home page
|
||||
$routeContext = RouteContext::fromRequest($request);
|
||||
$routeParser = $routeContext->getRouteParser();
|
||||
return $response
|
||||
->withHeader('Location', $routeParser->urlFor('test.view', [
|
||||
'test_id' => $result->test_id
|
||||
]))
|
||||
->withStatus(302);
|
||||
} else {
|
||||
$payload = json_encode('Success!');
|
||||
$response->getBody()->write($payload);
|
||||
return $response
|
||||
->withHeader('Content-Type', 'application/json');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user