[CLOSED] AjaxRequestException.Handler parameters

  1. #1

    [CLOSED] AjaxRequestException.Handler parameters

    Hi all

    I have AjaxRequestException.Handler defined on my Resource Manager but I want s different behavior for session expired event.
    What parameters I can pass on with a function that is a handler for this event please?
    So I can figure out what message am I getting as an exception and can act accordingly.

    Thank you
    Last edited by Daniil; May 22, 2015 at 8:46 AM. Reason: [CLOSED]
  2. #2
    Hi @registrator,

    If you run this example, choose ResourceManager and AjaxRequestException in the respective ComboBoxes, you'll see a set of parameters.
    https://examples2.ext.net/#/Events/Listeners/Arguments
  3. #3
    Wow, cool example. Thank you for pointing it out!
  4. #4
    Can you please help me defining the function for handling this?

    I got this:

        @Html.X().ResourceManager().ShowWarningOnAjaxFailure(false).AjaxTimeout(30000).Listeners(l => l.AjaxRequestException.Fn = "ajaxException(response, result, el, eventType, action, extraParams, o)")
    var ajaxException = function (response, result, el, eventType, action, extraParams, o) {
    
        Ext.Msg.alert('Application Error', 'Sorry, an error happened while processing your request. We apologize for the inconvenience!');
        return false;
    };
    In the browser I get: Response not defined and then I remove response and get Result not defined so I think I am doing something very wrong here.

    Thank you
  5. #5
    Please try:
    l.AjaxRequestException.Fn = "ajaxException"
    The Fn property's value should be just a function name.
  6. #6
    Thank you for the answer Daniil.
    When I define this like you suggest, the function is called on every page load even if there is no exception and all the parameters passed in are undefined.
  7. #7
    Please provide a test case.
  8. #8
    You can do it like this:

    Open your MVC examples solution.
    Fid Home.cshtml in the Views/Main folder
    Change @Html.X().ResourceManager() to
    @Html.X().ResourceManager().ShowWarningOnAjaxFailure(false).AjaxTimeout(30000).Listeners(l => l.AjaxRequestException.Fn = "ajaxException()")
    Find main.js file in the resources/js folder
    Add a reference to the main.js file in the Home page <head> tag
    <script src="@Url.Content("~/resources/js/main.js")"></script>
    Just before " if (window.location.href.indexOf("#") > 0) {" line at the bottom add
    var ajaxException = function (result, el, eventType, action, extraParams, o) {
    
        Ext.Msg.alert('Application Error', 'Sorry, an error happened while processing your request. We apologize for the inconvenience!');
        return false;
    };
    Set a brake-point in this function and as soon as your run the project you'll find it stops in this function with no exception thrown on first load of the home page.
    Last edited by registrator; May 20, 2015 at 4:07 PM.
  9. #9
    l.AjaxRequestException.Fn = "ajaxException()"
    That is not my suggestion :)

    My was:
    l.AjaxRequestException.Fn = "ajaxException"
  10. #10
    Oh, right. I apologize.
    It works of course.

    Thank you

Similar Threads

  1. Replies: 6
    Last Post: Sep 24, 2013, 6:55 AM
  2. [CLOSED] Hide AjaxRequestException Window
    By Tactem in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Nov 12, 2012, 1:21 PM
  3. Replies: 1
    Last Post: Sep 28, 2011, 3:50 AM
  4. groupcommand handler parameters
    By wp_joju in forum 1.x Help
    Replies: 4
    Last Post: Feb 16, 2011, 9:22 AM
  5. [CLOSED] Button AJAX Event and Handler Parameters
    By amitpareek in forum 1.x Help
    Replies: 3
    Last Post: Sep 17, 2008, 6:48 PM

Posting Permissions