1

在 JS 文件中,我正在执行此功能:

$(function() {
    $(".button").click(function() {

        //get the button's ID (which is equal to its row's report_id)
        var emergency = this.id;
        var button = this.attributes['name'].value;
        var dataString = 'reportid=' + emergency;

        alert(dataString);
        if (button == "clockin") {
            $.ajax({
                type: "POST",
                url: "/employeetimeclock.php",
                data: dataString,
                success: function() {
                    window.location = "/employeetimeclock.php";
                }
            });
        } else if (button == "closereport") {
            var r = confirm("Are you sure you want to close this report?\nThis action CANNOT be undone!");
            if (r == true) {
                $.ajax({
                    type: "POST",
                    url: "/closeemergencyreport.php",
                    data: dataString,
                    success: function() {
                        alert("Report Successfully Closed!");
                        window.location = "/closeemergencyreport.php";
                    },
                    error: function() {
                        alert("An error has occured, the report was not closed");
                    }
                });
            } else {
                alert("Report was not closed.");
            }
        }
    });
});

对于 else if(到 closeemergencyreport.php),该 php 脚本中的代码如下:

<?php

require_once("models/config.php");
require_once("models/header.php");
require_once("models/dbconnect.php");


$reportid = $_POST['reportid'];


var_dump($_POST);


$sql = "UPDATE emergency_report SET report_closed = '1' WHERE report_id IN ( $reportid )";
//execute and test if succesful
$result = mysql_query($sql) or die(mysql_error());
if($result){
} else{
}
?>

我在其他 3 个页面上做了同样的事情,它完美地工作,但这给我带来了麻烦,在那个 php 脚本上 VAR_DUMP 说它返回一个空数组。我已经阅读和重新阅读代码大约一个半小时了,所以我认为我已经筋疲力尽了,需要有一个外部的看法。我已经遍及整个网站,没有人找到适合我的解决方案。

我知道它正在发布,因为火虫在运行 javascript 的表单页面上显示了这个:http:
//i.imgur.com/hItdVU1.png(抱歉不能发布图片)

4

0 回答 0