Skip to content

Save Local Data Array Back to Server via Ajax

Below is the code snippet to submit local array back to server through Ajax POST. jQuery Form plugin is required. Users must supply their own server-side save routine URL e.g. "save_local_array.php". The edit.php provided with phpGrid only works with database data source. 

    <script src=""></script>
    <form id="admin_form">
            <input type="submit" value="Submit Local Changes">

        $(function() {
            // bind to the form's submit event
            $('#admin_form').submit(function(event) {
                    type: 'post',
                        langArray:[] //leave as empty array here
                    beforeSubmit: function(arr, $form, options){
                        options.langArray = $('#data1').jqGrid('getRowData'); //current
                        // return false; // here to prevent submit
                    success: function(){
                        // add routine here when success

                // return false to prevent normal browser submit and page navigation
                return false;

The data format posted back to the server is JSON format. 

Visit and select "Local Array" demo, enable browser console, and the hit "Submit local changes" button, you should see a sample of the JSON data similar to the below posted back to the server.  


Feedback and Knowledge Base