php中的get方法无法使用bootgrid

时间:2016-04-15 08:55:05

标签: javascript php html

你帮我解决了这个问题吗? 我试图在命令编辑中选择一个项目时传递所选值以在bootgrid中创建查询但我在get方法中遇到问题这是我的代码 感谢

<?php
//include("formClient.php");

if (isset($_GET["id"])) { $ClientId  = $_GET["id"]; } else { $ClientId=0; };
echo $ClientId;

function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}  

?>

<script langauge="javascript">

    var grid = $("#grid-data").bootgrid({
        ajax: true,
        ajaxSettings: {
            method: "GET",
            cache: false
        },
    url: "clientdata.php",
    formatters: {
        "commands": function(column, row)
        {
            return "<button type=\"button\" class=\"btn btn-xs btn-default command-edit\" data-row-id=\"" + row.ClientId + "\"><span class=\"glyphicon glyphicon-pencil\"></span></button> " +                    
                "<button type=\"button\" class=\"btn btn-xs btn-default command-delete\" data-row-id=\"" + row.ClientId + "\"><span class=\"glyphicon glyphicon-trash\"></span></button>";
        }
    }
}).on("loaded.rs.jquery.bootgrid", function()
{
    /* Executes after data is loaded and rendered */
    grid.find(".command-edit").on("click", function(e)
    {   
        var id=$(this).data("row-id");

        $.ajax({
            url: '<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>',
            type: "GET",
            data: ({id: id}),
            success: function(data){
                console.log(data);
                alert(data);
            }
        }); 

    }).end().find(".command-delete").on("click", function(e)
    {
        //alert("You pressed delete on row: " + $(this).data("row-id"));

        var x;
        if (confirm("Are you sure to delete this record?") == true) {
            x = "OK";
        } else {
            x = "CANCEL";
        }
        if (x=="OK"){
            //window.location.href="DeleteClient.php?id="+ $(this).data("row-id");
        }               
    });
}); 
</script>

0 个答案:

没有答案