Why isn't my code works when im trying to force download file inside a page which im loading with ajax?
this is the page code which im loading with ajax into another page:
// Set headers
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=$file");
// Read the file from disk
Forcing a file to download (using the headers like you have there) is done simply by linking to the file from within a web page. No ajax is required.
Ajax will not work here (as Fegall mentioned);