首页 > 解决方案 > 为什么 post-command 仅适用于以下警报?

问题描述

我有一个 ajax 调用(实际上是发布),如果后面跟着 alert('hello'); (sqlite 数据库由 ajaxgastverg.php 更新,关闭警报报告其数据和成功)。

删除警报(“Hello”)后,帖子不起作用(ajaxverg.php 不会更新 sqlite 数据库,并且关闭警报不会出现数据和成功)。

如何在没有警报(“Hello”)的情况下使帖子工作?

查阅以前的报告,我试图删除警报('Hello')并替换为“return false;”但这没有帮助。

function popupgastverg2()  
{nr=$('#popupgastverg').data('nr');
cat=$('#popupgastverg select').find(":selected").text();
$.post
    ("ajaxgastverg.php"
    ,{catin:cat,nrin:nr}
    ,function(data,status)
        {alert('data='+data+"\nstatus="+status);
        // I tried here return false; but no effect
        }
    );
    // I tried here return false; but no effect
alert("Hello"); // THIS WAS FOR DEBUGGING ONLY
}

标签: javascriptajax

解决方案


我找到了“解决方案”,但我不明白。我希望其他人可以从中受益,尽管我没有解释。

程序被调用

<form id='xxx'> ..... more...
<button onclick="popupgastverg2();"> Deel list </button>
....more...
</endform>

一旦我将按钮更改为:

<button type='button' onclick="popupgastverg2();"> Deel list </button>

一切正常。惊喜,更是惊喜!


推荐阅读