How do i run a PHP function inside jQuery click event. I have the following which is not correct. when the user clicks on a button, i want a new directly created.
You can greatly benefit from a framework supporting AJAX.
As author of Agile Toolkit I can recommend you to try it, the code would look like this:
$button=$page->add('Button');
if($button->setLabel('Create Directory')->isClicked()){
if(mkdir('/tmp/123', 0777, true)){
$button->js()->univ()->alert('Directory Created'); // executes JS code
}else{
$button->js()->univ()->alert('Problem'); // executes JS code
}
}
Other frameworks may offer other ways to simplify AJAX and keep it in one file.