Search code examples
javascriptphpjsgrid

update items using jsGrid


I wanna use the jsGrid library into my site web, can you help me? I will be very thankful. How can I send the updated items to the php code update.php? This is what I have tried but it doesn't work for me. I get white cells:

  updateItem: function(item) { 
     var d = $.Deferred();
       $.ajax({
                type: "GET",
                url: "update.php",
                data:{name:item.name}
            }).done(function(response) {
                d.resolve(response);
            }).fail(function() {
                d.resolve(previousItem);
            });
            return d.promise();
    }

update.php:

<?php
include("connexion.php");
$sql = "UPDATE servers SET name = '".$_GET['name']."' WHERE id = 1";
if( $result = pg_query($sql))    
{  
echo 'Data Updated';  
}
?>

Solution

  • Checkout the sample project for php + jsgrid https://github.com/tabalinas/jsgrid-php. It shows how to implement update correctly on both the front-end and back-end sides.