javascript - 为什么 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
}
解决方案
我找到了“解决方案”,但我不明白。我希望其他人可以从中受益,尽管我没有解释。
程序被调用
<form id='xxx'> ..... more...
<button onclick="popupgastverg2();"> Deel list </button>
....more...
</endform>
一旦我将按钮更改为:
<button type='button' onclick="popupgastverg2();"> Deel list </button>
一切正常。惊喜,更是惊喜!
推荐阅读
- swift - 如何在 RealityKit 中访问 Reality Composer 的模型组件?
- javascript - 对象属性在更新时会覆盖所有网格
- c# - 将 Crystal Report 与数据集连接起来
- java - 如何使用 POI 删除表格后的第一个字符
- c# - 如何在 .NET Standard 2.0/Core 2.1 中使用 PrivateKey 创建 X509Certificate2?
- ubuntu-18.04 - 无法连接到我的世界远程服务器:连接被拒绝
- algorithm - 使用数组构建 BST 并查询新的节点插入级别/深度
- url - 是否有任何理由从 URL 中共同复制代码行?
- reactjs - ReactJS,我想将组件转换为 pdf,还要滚动页面
- r - 为什么闪亮没有在服务器会话中调用本地函数?