Run php function inside jQuery click

后端 未结 9 775
醉酒成梦
醉酒成梦 2020-12-03 12:19

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.

         


        
9条回答
  •  萌比男神i
    2020-12-03 12:53

    You cannot run PHP code inside a jquery function. PHP runs on the server-side whereas jquery/javascript runs on the client-side. However, you can request a PHP page using jquery and with the PHP code on that page will run the mkdir that you want.

    JS:

    $.ajax({
      url: 'test.php',
      success: function(data) {
        alert('Directory created');
      }
    });
    

    test.php FILE:

     
    

提交回复
热议问题