Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript button ajax and php

I have a small question, which I guess in my opinion will sound stupid. I have actually this code

<script type="text/javascript">
$(document).ready(function(){

var email_value = prompt('Please enter your email address');
if(email_value !== null){
//post the field with ajax
$.ajax({
    url: '="/new/cfolder.php',
    type: 'POST',
    dataType: 'text',
    data: {data : email_value},
    success: function(response){ 
     //do anything with the response
      console.log(response);
    }       
}); 
}

});
</script>

I would like to link it to my button which does this

<form action="/new/cfolder.php" method="post">
    </font><input type="submit" value="Create Vdisk" class="myButton6" onClick="function()"> 
<br></form>

Is it actually possible to do this? thank you for any answer.

like image 798
Setth Kerykeion Avatar asked Aug 06 '26 07:08

Setth Kerykeion


1 Answers

 <script type="text/javascript">
  $(document).ready(function(){
    $(document).on('click', '.myButton6', function(){
      var email_value = prompt('Please enter your email address');
      //post the field with ajax
      if(email_value.length > 0){
        $.ajax({
            url: '/new/cfolder.php',
            type: 'POST',
            dataType: 'text',
            data: {data : email_value},
            success: function(response){ 

              alert(response);
            }       
        }); 
      }
    )};
  }); 
</script>

try that way

like image 198
Legendary Avatar answered Aug 07 '26 21:08

Legendary



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!