When a user clicks on a link, I want to move the files from one folder to another (by ajax)
The php move file works fine, but the ajax part doesnt seem to be working.
Ajax called in JS script:
function moveFiles() {
$.ajax({
url: "http://localhost/website/controller/moveFiles",
});
}
(Cake)PHP function
public function moveTmpFiles() {
$source = new Folder(WWW_ROOT . "uploadify/tmpFiles");
$unsavedFiles = new Folder(WWW_ROOT . "uploadify/unsavedFiles");
$this->moveFiles($source->path, $destination_path->path);
}
JQuery function
$( "#element" ).click(function(event){
event.preventDefault();
moveTmpFiles();
$( "#myDialog" ).dialog( "open" );
});
I guess I should add more options to the $.ajax call, but the real questions here is this:
Which options on jquery ajax calling are necessery to get it work?
You have a JS function named
moveFiles()and you’re callingmoveTmpFiles();, which is the PHP function.Change your jQuery function as follows.
As a side note, do not use absolute paths. When you move your application to the production server, you’ll have to change all the URLs in your code.