gpt4 book ai didi

javascript - Onclick 与提交按钮无法正常工作

转载 作者:行者123 更新时间:2023-11-28 19:23:41 25 4
gpt4 key购买 nike

我想为提交按钮添加onlick。我用谷歌搜索许多教程网站都实现了所有提示,但所有这些都不能解决问题。当我将警报放入被调用的函数中时,警报正在工作但 page-join.php 中的任务不起作用。当我把onclick 与效果很好的图像。有什么问题请指导,由于表单提交,我在 firebug 中没有遇到问题安慰。所以我不明白真正的问题是什么。

//This is my function that i am calling from onclick.

function deltpopdtl()
{
var ipss = '<?php echo $baseUrl ;?>/themes/gr-mist/includes/';

$.ajax({
url: ipss+"page-join.php?delpopdtl=<?php echo $_GET['pageid'];?>",
success: function(data){
}
});}


// This is my php code(page-join.php)
if(isset($_GET['delpopdtl']))
{
global $db;
$getdetail = "DELETE FROM firstloadpop WHERE rsc_id=".$_GET['delpopdtl']." and user_id= $user_id";

mysql_query($getdetail);
}
//This is my form and submit button
<form method="post" id="" enctype="multipart/form-data" action="#">

<input type="submit" id="abc" name="onladinvite" value="sendinvitation" onclick="return deltpopdtl();" />
//i put only onlick deltpopdtl(); but the same situation, i also tired
//onclick="return deltpopdtl();return false" but all vain

</form>

最佳答案

  1. You have to write return false before function end because your form is submitted and you cant see your ajax effect.

  2. You can change your submit button to type='button'

function deltpopdtl()
{
var ipss = '<?php echo $baseUrl ;?>/themes/gr-mist/includes/';
$.ajax({
url: ipss+"page-join.php?delpopdtl=<?php echo $_GET['pageid'];?>",
success: function(data){}
});
return false; //You have to add this line because your form is submitted and you cant see your ajax effec
}

关于javascript - Onclick 与提交按钮无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28315250/

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