php - 剑道网格点击新的更新按钮没有努力

标签 php jquery mysql kendo-ui kendo-grid

我使用kendo UI网格并连接到Mysql, 功能更新和读取是可以的,但是当我使用创建并在新行中输入一些数据时,然后我单击更新但没有任何作用。 我不知道出了什么问题? 我的网格是:

$("#grid").kendoGrid({
        dataSource: {
            transport: {
                read: "data/channels.php",
                update: {
                    url: "data/channels.php",
                    type: "POST"
                },
                create: {
                    dataType: "json",
                    url: "data/channeladd.php",
                    type: "POST"
                }
            },
            schema: {
                data: "results",
                model: {
                    id: "channelId",
                    fields: {
                        channelName: { validation: { required: true} }
                    }
                }
            }
        },
        columns: [{ field: "channelName", title: "Channel Name" }, { field: "channelIp", title: "Channel Ip" }, { field: "channelPort", title: "Channel Port" }, { command: ["edit", "destroy"], title: " ", width: "172px" }],
        editable: "inline",
        navigable: true,  // enables keyboard navigation in the grid
        toolbar: [ "create" ]  // adds save and cancel buttons
    });

在channeladd.php中:

$link = mysql_pconnect("localhost", "root", "THE PASSWORD") or die("Unable To Connect To Database Server");
mysql_select_db("THE DB") or die("Unable To Connect To THE DB");

// add the header line to specify that the content type is JSON
header("Content-type: application/json");

    $request = json_decode(file_get_contents('php://input'));

    // DISCLAIMER: It is better to use PHP prepared statements to communicate with the database.
    //             this provides better protection against SQL injection.
    //             [http://php.net/manual/en/pdo.prepared-statements.php][4]

    // get the parameters from the get. escape them to protect against sql injection.

    $channelnName = $request["channelName"];
    $channelnIp = $request["channelIp"];
    $channelnPort = $request["channelPort"];

    $sql = "INSERT INTO channel (channelName, channelIp, channelPort) VALUES (".$channelnName.",".$channelnIp.",".$channelnPort.")";

    $rs = mysql_query($sql);

    if ($rs) {
        echo true;
    }
    else {
        header("HTTP/1.1 500 Internal Server Error");
        echo false;
    }

enter image description here

任何建议表示赞赏。

最佳答案

抱歉,我不知道原因,但是当我删除该行时:

header("Content-type: application/json");

任何操作都可以。感谢您的关注,迪普:)

关于php - 剑道网格点击新的更新按钮没有努力,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18627175/

相关文章:

php - 使用 PHPExcel lib 导入带制表符分隔的 CSV 文件

php - 删除成员(member)数据库中注册的成员(member)

jquery - 当 div 元素可见时检测按键

javascript - 如何动态更改动态div的div文本

mysql - Hibernate、MySQL 编码在 debian 上不起作用

javascript - Jquery Ajax不向php服务器发送数据

php - self::__construct() 和 new self() 之间的确切区别

php - file_get_contents 不适用于 tmp 文件

jquery - 获取倒数第二个元素

php - NULL 分配给 mysql_fetch_array 输出?