On Click File Download, On Success Redirect To Another Page Using Ajax
In my WordPress project, my Download button containing a .zip file, which onClick should be downloaded. So the HTML producing is: >Download</a>
Above can be url link to download and below will be php code in download.php
//code to update download count (UPDATE tbl_dwn SET total = total + 1)//below is code to download (hope you know it)$zipName = $_GET['file']; //here you've to specify the absolute path to the download.zip file
header("Content-type: application/zip");
header("Content-Disposition: attachment; filename=".$zipName."");
header("Content-length: " . filesize($zipName));
header("Pragma: no-cache");
header("Expires: 0");
readfile($zipName);
Try out this and let me know if you've any problem.
Solution 2:
Try this,
Will take you to another page
success: function (data) {
window.location.href = site.url + "/download-success?fid="+ id;
}
Will take you to another page in the new window
success: function (data) {
window.open('site.url + "/download-success?fid="+ id');
}
Post a Comment for "On Click File Download, On Success Redirect To Another Page Using Ajax"