Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
15
Iggrid SaveChanges Does not Recognize Success Message from Update Url
posted

Hi, I am trying to batch update my grid with an updateUrl. However, I cannot get the grid to recognize that the php file I am hitting returns success. Instead, the error callback happens. This question is the same as this, except the suggested answer does not work for me (I am setting the header and the problem still occurs.) 

Here is the code for my webpage.

<!DOCTYPE html>
<html>
<head>
    <title></title>

    <!-- Ignite UI Required Combined CSS Files -->
    <link href="http://cdn-na.infragistics.com/igniteui/2018.1/latest/css/themes/infragistics/infragistics.theme.css" rel="stylesheet" />
    <link href="http://cdn-na.infragistics.com/igniteui/2018.1/latest/css/structure/infragistics.css" rel="stylesheet" />

    <script src="http://ajax.aspnetcdn.com/ajax/modernizr/modernizr-2.8.3.js"></script>
    <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
    <script src="http://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script>

    <!-- Ignite UI Required Combined JavaScript Files -->
    <script src="http://cdn-na.infragistics.com/igniteui/2018.1/latest/js/infragistics.core.js"></script>
    <script src="http://cdn-na.infragistics.com/igniteui/2018.1/latest/js/infragistics.lob.js"></script>

</head>
<body>

    <table id="grid"></table>
    <button onclick="saveGridChanges();">Save</button>
    <label id="message"></label>
    <script src="https://www.igniteui.com/data-files/nw-products.js"></script>
    <script>
        $(function () {
            $("#grid").igGrid({
            	primaryKey: "ProductID",
            	caption : "<span> <img src=\"//www.infragistics.com/media/441501/horz_logo.png\" alt=\"Infragistics\"></span>",
                width: '100%',
                columns: [
                    { headerText: "Product ID", key: "ProductID", dataType: "number", width: "15%", hidden: true },
                    { headerText: "Product Name", key: "ProductName", dataType: "string", width: "25%" },
                    { headerText: "Category", key: "CategoryName", dataType: "string", width: "25%" },
                    { headerText: "Units In Stock", key: "InStock", dataType: "number", width: "35%" }
                ],
                autofitLastColumn: false,
                autoGenerateColumns: false,
                dataSource: northwindProducts,
                responseDataKey: "results",
                autoCommit: false,
                updateUrl: "http://localhost:8001/php/formrequests/common/test.php",
                features: [
                    {
                        name: "Updating",
                        editMode: "row",
                        enableAddRow: false,
                        columnSettings: [
                            {
                                columnKey: "ImageUrl",
                                readOnly: false
                            }
                        ]
                    }
                ]
            });
        });
        function saveGridChanges() {
    try {

        $("#grid").igGrid("saveChanges",
        function (data) {
            $("#message").text("Changes were saved successfully").fadeIn(3000).fadeOut(5000);

            }, function (jqXHR, textStatus, errorThrown) {
            alert(JSON.stringify(jqXHR));
            alert(errorThrown);
            alert(JSON.stringify(textStatus));
            $("#message").text("An error occurred while saving the changes. Error details: " + textStatus).fadeIn(3000).fadeOut(5000);
        });
    } catch (e) {
        alert("error");
    }
}
     </script>
</body>
</html>

Here is the code of the php file in the update url. 

<?php
header('Content-Type: application/json; charset=utf-8');
echo (json_encode(array('success' => true)));
?>

Thank you