EasyUI Forum
May 06, 2024, 09:19:06 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Request: eDatadrip posting json data  (Read 5726 times)
Silas
Newbie
*
Posts: 1


View Profile Email
« on: April 27, 2016, 02:09:00 AM »

Hello,

I'm using eDatagrid with json backend. When I use save, delete or create urls, the data is posted in form-data format.

Is there a way to post json data since that's the format the data is delivered to the grid?

I do not want to handle two different data-formats on my backend and have not found a solution to convert form data to json.

Best regards,
Jan
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: April 27, 2016, 07:41:38 PM »

You can custom the post method by overriding the 'poster' function. Be sure to download the newest 'jquery.edatagrid.js' file from http://www.jeasyui.com/extension/edatagrid.php
Code:
$('#dg').edatagrid({
    poster: function(url, data, success, error){
        $.ajax({
            type: 'post',
            url: url,
            data: data,  // JSON.stringify(data)
            dataType: 'json',
            success: function(data){
                success(data);
            },
            error: function(jqXHR, textStatus, errorThrown){
                error({
                    jqXHR: jqXHR,
                    textStatus: textStatus,
                    errorThrown: errorThrown
                });
            }
        });
    }
});
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!