gpt4 book ai didi

javascript按钮ajax和php

转载 作者:搜寻专家 更新时间:2023-10-31 21:31:35 24 4
gpt4 key购买 nike

我有一个小问题,我想这听起来很愚蠢。我实际上有这段代码

<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>

我想将它链接到执行此操作的我的按钮

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

这真的可行吗?谢谢你的任何回答。

最佳答案

 <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>

试试看

关于javascript按钮ajax和php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29489153/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com