Closed. This question is off-topic。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
                        
                        4年前关闭。
                                                                                            
                
        
我正在尝试在php文件中调用一个函数,该函数将触发查询以从表和数据库中删除行,但似乎无法使其正常工作

这是按钮:

<td><a href="../service/deleteModule.php?id='.$row['id'].'"><img src="../web/img/delete.png" height='25' onclick="delete()" width='25' alt='delete'/></a></td>

最佳答案

您可以在JavaScript中使用XMLHttpRequest。

myWebpage.html

var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
        // Row deleted successfully
        alert(xmlhttp.responseText)
    }
}
xmlhttp.open("GET", "deleteRow.php?rowWhichNeedsToBeDeleted=" + rowId, true);
xmlhttp.send();


myPHP.php

<?php
    $rowId = $_GET["rowWhichNeedsToBeDeleted"];
    Code to delete row...
    echo "Success";
?>


有关更多信息,请访问:http://www.w3schools.com/php/php_ajax_php.asp

希望这可以帮助。

10-07 21:45