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.
First of all you should understand how php works (no offense but this is essential). Why PHP script is not workig in a web browser? To accomplish what you need you have to use ajax (to request a script on the server using javascript)
PHP File (createdir.php):
JavaScript Code:
$('button').click(function() {
$.ajax({
url: 'createdir.php',
success: function(){
alert('dir created');
}
});
return false;
});
I have not validated if the code acually works. If you encounter any problems you should have a look at the jquery documentation (it's awsome :-) ) http://api.jquery.com/jQuery.ajax/