yosafat yosafat - 3 months ago 26
jQuery Question

Jquery is it possible to refresh page if download start?

i have an application which the user choose the

press button
and download the data based on checked box,
the problem is if i am not checking any
, it will show
message in
and when i check and click download, download run well, but the error message is still in the page.
how to detect if download start, automatically page refresh, or how to solve it more easily?

my download code :

public function downloadFile($name)
$storagePath = "/opt/tmp/";

// check filename for allowed chars (do not allow ../ to avoid security issue: downloading arbitrary files)

if (!is_file("$storagePath/$name")) {
throw new \yii\web\NotFoundHttpException('The file does not exists.');
return Yii::$app->response->sendFile("$storagePath/$name", $name);

how i can make detect download start and refresh it using jquery?


You need to Hide the Error message as soon as you click on Checkbox. something Like that $("#id").hide();

Here id is the Id of the error message div