This is a migrated thread and some comments may be shown as answers.

Handle AJAX request

3 Answers 276 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jose Manuel
Top achievements
Rank 1
Jose Manuel asked on 17 Jan 2012, 04:39 PM
Hello,

When I have any kind of error my JSON response is like:

{ error: true, message: "Error caused ....", date: "date ... " },

When I make an AJAX conn by myself I can check whether there has been any error or not, but how can I check it when kendoGrid makes a connection to "Save data"?

Thanks. 

3 Answers, 1 is accepted

Sort by
0
Accepted
John DeVight
Top achievements
Rank 1
answered on 17 Jan 2012, 05:20 PM
Hi Jose,

I haven't seen a way to do this within the grid, but I have had to do something very similar to this.  The jQuery.ajaxSuccess() function should provide you with the ability to "listen" to all the Ajax calls being made.  You could try the following:

$('#grid').ajaxSuccess(function (e, xhr, settings) {
    // If the Ajax call made to the SaveGridInfo method...
    if (settings.url.indexOf('/Home/SaveGridInfo')!= -1) {
        // Was the response an error?
        var response = JSON.parse(xhr.responseText);
        if (response.error != undefined && response.error == true) {
            // Display the error.
            alert(response.message);
        }
    }
}

Hope this helps....

Regards,

John DeVight
0
Jose Manuel
Top achievements
Rank 1
answered on 17 Jan 2012, 05:33 PM
Thanks a lot.

I worked fine :)
0
John DeVight
Top achievements
Rank 1
answered on 17 Jan 2012, 05:39 PM
Glad to hear it worked out!

Let me know if there is anything else I can do to help.

If you get a chance, could you mark the response as the answer so that other forum users will know... =)  Thanks!

Regards,

John DeVight
Tags
Grid
Asked by
Jose Manuel
Top achievements
Rank 1
Answers by
John DeVight
Top achievements
Rank 1
Jose Manuel
Top achievements
Rank 1
Share this question
or