Handle AJAX request

4 posts, 1 answers
  1. Jose Manuel
    Jose Manuel avatar
    3 posts
    Member since:
    Oct 2011

    Posted 17 Jan 2012 Link to this post

    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. 
  2. Answer
    John DeVight
    John DeVight avatar
    209 posts
    Member since:
    Jan 2010

    Posted 17 Jan 2012 Link to this post

    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
  3. Kendo UI is VS 2017 Ready
  4. Jose Manuel
    Jose Manuel avatar
    3 posts
    Member since:
    Oct 2011

    Posted 17 Jan 2012 Link to this post

    Thanks a lot.

    I worked fine :)
  5. John DeVight
    John DeVight avatar
    209 posts
    Member since:
    Jan 2010

    Posted 17 Jan 2012 Link to this post

    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
Back to Top
Kendo UI is VS 2017 Ready