0
Q
通过单击
A
回答
0
有达到你正在尝试做不同的方式。 我认为虽然“最干净”将使用jquery(javascript)来操作事件处理程序。
像这样的工作:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<div>
<a href="abc.html">click me</a>
</div>
<script>
$(function() {
$("a").click(function (e) {
var url = $(this).attr("href"); // Here we retrieve the href of clicked link
var res = $.ajax({
type: "POST",
data: {
url: url // The left side is the request key (so: $_POST['url'])
},
url: "https://url/to/handler.php",
async: false
}).responseText;
console.log(res);
if(res == "success") return true; // returning true lets the browser follow the link
else return false; /* so if it didn't work, the link will not be
followed. Of course you can do at these two
points whatever you like. */
})
});
</script>
在PHP的成功简单地echo如果插入成功。
请注意,虽然不赞成使用AJAX请求的async:false。
+0
这确实奏效,非常感谢 –
相关问题
- 1. 通过单击
- 2. 通过单击DIV
- 3. 通过单击X按钮
- 4. 通过单击链接
- 5. 如何通过单击行
- 6. 通过单击按钮
- 7. 通过单击警报
- 8. 通过单击GridView的C#
- 9. 通过单击的UIButton
- 10. 通过单击通知调用Firebase onMessageReceived
- 11. 通过单击获取单词
- 12. 通过单击箭头在树上加载节点3通过单击箭头
- 13. 如何通过单击右键单击段落中的单词?
- 14. 通过点击增加单元格值
- 15. 通过单击栏获取YValue
- 16. 如何通过单击链接
- 17. jQuery Tablesorter - 通过单击链接排序
- 18. 通过单击列标题排序radGridView
- 19. 通过单击事件禁用锚点
- 20. 通过点击菜单选项
- 21. 导航图标无法通过单击
- 22. 通过我的类NG单击
- 23. C#表单点击通过表格
- 24. 通过单击按钮创建表格
- 25. 通过发送消息单击鼠标
- 26. 通过单击动画循环
- 27. 通过单击图像重置textfield
- 28. 通过单击链接应用css
- 29. 如何通过单击事件document.getElementById(“someid”)
- 30. 通过单击并拖动创建div
有几种方法可以做到这一点。您应该提供更多信息,例如是应该打开的网站,如果是这样的话,如果html实际上包含了php代码,那么这很好吗? – Daidon