Forum

July 12th, 2025
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
JSON Post Format?
13/08/2009
10:40
Avatar
Sloan Thrasher
Guest
Guests

Hi all,

How do I find out the format of the requests sent to the server?

I've searched the forums, and the documentation, but haven't been able to find the info.

Any help would be greatly appreciated!

TIA

Sloan

13/08/2009
10:53
Avatar
Matthew
Guest
Guests

If you're going to be posting JSON you're probably better of using a custom data function like this..

setup your grid with the datatype option set as

datatype : function(pdata) { getData(pdata); }

and here is the function.... note the params object which is what i send JSONified to my webservice... which can be anything you want... and in my case the data that gets sent is...

{"page":1,"pageSize":25,"sortIndex":"id","sortDirection":"desc"}

see how they match my "params" object ...

    function getData(pdata) {
        var params = new Object();
        params.page = pdata.page;
        params.pageSize = pdata.rows;
        params.sortIndex = pdata.sidx;
        params.sortDirection = pdata.sord;

        $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: "YourWebservice.asmx/GetGridData",
            data: JSON.stringify(params),
            dataType: "json",
            success: function(data, textStatus) {
                if (textStatus == "success") {
                    var thegrid = $("#YourGrid")[0];
                    thegrid.addJSONData(data.d);
                }
            },
            error: function(data, textStatus) {
                alert('An error has occured retrieving data!');
            }
        });
    }

13/08/2009
12:08
Avatar
Sloan Thrasher
Guest
Guests

Matthew said:

If you're going to be posting JSON you're probably better of using a custom data function like this..

setup your grid with the datatype option set as

datatype : function(pdata) { getData(pdata); }

and here is the function…. note the params object which is what i send JSONified to my webservice… which can be anything you want… and in my case the data that gets sent is…

{”page”:1,”pageSize”:25,”sortIndex”:”id”,”sortDirection”:”desc”}

see how they match my “params” object …

    function getData(pdata) {
        var params = new Object();
        params.page = pdata.page;
        params.pageSize = pdata.rows;
        params.sortIndex = pdata.sidx;
        params.sortDirection = pdata.sord;

        $.ajax({
            type: “POST”,
            contentType: “application/json; charset=utf-8″,
            url: “YourWebservice.asmx/GetGridData”,
            data: JSON.stringify(params),
            dataType: “json”,
            success: function(data, textStatus) {
                if (textStatus == “success”) {
                    var thegrid = $(”#YourGrid”)[0];
                    thegrid.addJSONData(data.d);
                }
            },
            error: function(data, textStatus) {
                alert('An error has occured retrieving data!');
            }
        });
    }


Hi Jason,

I've got the format for sending the data to the grid. I'm wanting to know what format the data is sent to the server.

TIA!

Sloan

13/08/2009
14:50
Avatar
Matthew
Guest
Guests

Mmm my post tells you one of the available formats...

btw who is Jason O_o

14/08/2009
10:49
Avatar
Sloan Thrasher
Guest
Guests

Matthew said:

Mmm my post tells you one of the available formats…

btw who is Jason O_o


Sorry 'bout that Matthew!, must have been cranial flatulance on my part.

I must be confused. In reading your post above, it appeared to be just the format to send to the server. I'm an ASP (classic) programmer, so the PHP examples haven't helped. I guess I'm wondering how the submit to the ASP program will look. For instance, what is the name of the submitted info in the request object? How do the rows appear when saving data from the grid?

My guess from your example is that I'll get a form value for each of the parameters (i.e. page, pagesize, sortiindex, and sortdirection) If I specify each column in a row, will I receive a form value for "row", and then the fields in the row?

Thanks for your patience!

Sloan

14/08/2009
11:07
Avatar
Sloan Thrasher
Guest
Guests

Hi Matthew!

Never mind -- I think I found it! You example was very helpful and got me going in the right direction.

Sloan

26/02/2010
19:11
Avatar
partoo
Member
Members
Forum Posts: 3
Member Since:
25/02/2010
sp_UserOfflineSmall Offline

Hi Sloan!

Can you give me your solution?

Forum Timezone: Europe/Sofia

Most Users Ever Online: 994

Currently Online:
44 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information