echo('<a class="block" href="block.php" title="Block User"><i class="fa fa-ban" aria-hidden="true"></i></a> <br>');
That is the line of code for blocking a user. But instead of using href to link to block.php can I instead call a function(that is already on the page) and simply have it to where when you click it it runs the function?
答案 0 :(得分:0)
您可以在该图标上创建按钮并在点击时调用javascript函数。这个函数将用于block.php。
取代
<a href = ""></a>
地点
<button type="button" id="btnSend"><i class="fa fa-ban" aria-hidden="true"></i></button>
现在 js :
<script>
$(document).ready(function () {
$("#btnSend").click(function () { //this function will call when user click the button
$.ajax({
url: 'block.php', //url of that block.php any other if link is different
type: 'POST',
data: "data", //data if there is any
success: function (result) {
alert('success');
}
});
});
});
</script>