Suppress "The server method 'xxxx' failed" (Web service)

9 posts, 0 answers
  1. Steve
    Steve avatar
    7 posts
    Member since:
    Jun 2012

    Posted 14 Nov 2013 Link to this post

    Context: I'm using as RadSearchBox and calling a web service using:

    <WebServiceSettings Path="~/Service.asmx"  Method="GetSearchBoxResults" ></WebServiceSettings>

    Just to be clear, my code works.

    However, on the odd occasion, especially if there is a delay in the response from the server, and the user tries navigating the page away before the response has been received, the error message "The server method 'xxx' failed" appears several times, which is irritating to users.

    Is there a straight forward way to suppress this message?

     


  2. Plamen
    Admin
    Plamen avatar
    2734 posts

    Posted 18 Nov 2013 Link to this post

    Hi Steve,

    One way to not show this error is to override the internal client event that shows it in RadSearchBox. Here is that code that should work  for you:

    Copy Code
    <script type="text/javascript"
                
                 Telerik.Web.UI.RadSearchBox.prototype._onError= function(args) {
                     var errorMessage = $T.RadSearchBox._extractErrorMessage(args);
     
                    // alert(errorMessage);
                 }
     
             </script>

    Hope this will solve the issue. If you have more questions I will be glad to assist you again.

    Regards,
    Plamen
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Tarek
    Tarek avatar
    23 posts
    Member since:
    Mar 2013

    Posted 06 Jan 2014 Link to this post

    when using :
     
               $(window).load(function () {
                    Telerik.Web.UI.RadSearchBox.prototype._onError = function (args) {
                        var errorMessage = $telerik.RadSearchBox._extractErrorMessage(args);
                        alert(errorMessage);
                    }
                });

    This error fire :
    Uncaught TypeError: Cannot call method '_extractErrorMessage' of undefined
  5. Plamen
    Admin
    Plamen avatar
    2734 posts

    Posted 07 Jan 2014 Link to this post

    Hi,

    You should define the $T as in the code below instead of $telerik:
    var $T = Telerik.Web.UI;

    Hope this will solve the issue.

    Regards,
    Plamen
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  6. Andrew
    Andrew avatar
    39 posts
    Member since:
    Feb 2011

    Posted 17 May in reply to Plamen Link to this post

    I am having exactly this problem with Chrome, but with a RadMenu with webservice-filled items. If you begin page navigation by clicking on something, then hover over the menus, then you get the "The Server Method xxx failed" dialog.

    I've tried using the code shown, replacing RadSearchBox with RadMenu, but it doesn't work - while tracing, Telerik.Web.UI doesn't have RadMenu, or RadSearchBox for that matter, as objects, so they are undefined, and therefore I can't access the prototype object.

  7. Plamen
    Admin
    Plamen avatar
    2734 posts

    Posted 20 May Link to this post

    Hello,

    In such case you can use the OnClientItemPopulationFailed event and cancel it in case you want to prevent the default error message.

    Regards,
    Plamen
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  8. Andrew
    Andrew avatar
    39 posts
    Member since:
    Feb 2011

    Posted 20 May in reply to Plamen Link to this post

    I already do that - but it doesn't actually reach it the function. That got me thinking, and now - I'm convinced the error is raised from the AJAX libraries, not Telerik's! The solution I have found, which works perfectly is to detect the page being reloaded (from a navigation click), then jQuery select all the RadMenu's on the page, and disable them! As we say, "A sledgehammer to crack a nut", but if you've clicked to go somewhere else, why would you be continuing to use menus, etc anyway...
  9. Andrew
    Andrew avatar
    39 posts
    Member since:
    Feb 2011

    Posted 18 Jul Link to this post

    OK, so my fix doesn't actually work for one edge case. This only affects chrome, and is as follows :

    We have a menu with thousands of items, and is populated with a webservice. We operate a 'pre-cache' system where when you open a child menu item, and children of that item that also has children, is populated in the background by manually calling the _loadChildrenFromWebService() function. However, if you open a menu item, with 8 children, then 8 webservice requests are queued up, and appear in the Chrome dev tools as 'pending', if then, the page is navigated away (by clicking on a link or something), then any of these 8 requests that are still Pending, get changed to Cancelled (as expected), but the browser raises the error which is the title of this thread. This is not trappable anywhere as far as I can tell, and you don't get the error for items failing to load.

    What I need is a way to pick up any of these Pending XMLHTTPRequest calls and set them to Abort.

    I have found a similar solution to a problem with Ajax requests doing this, and found a bit of script which automatically keeps track of open Ajax requests, and allow you to 'AbortAll' on any open ones. Is there anything that can be done similarly for the RadMenu item requests?

    $(function () {
        $.xhrPool = [];
        $.xhrPool.abortAll = function () {
            $(this).each(function (i, jqXHR) {   //  cycle through list of recorded connection
                jqXHR.abort();  //  aborts connection
                $.xhrPool.splice(i, 1); //  removes from list by index
            });
        }
        $.ajaxSetup({
            beforeSend: function (jqXHR) { $.xhrPool.push(jqXHR); }, //  annd connection to list
            complete: function (jqXHR) {
                var i = $.xhrPool.indexOf(jqXHR);   //  get index for current connection completed
                if (i > -1) $.xhrPool.splice(i, 1); //  removes from list by index
            }
        });
    })

  10. Plamen
    Admin
    Plamen avatar
    2734 posts

    Posted 21 Jul Link to this post

    Hello,


    Unfortunately I could not replicate the described issue at my side. In general we don't have a special approach for such custom scenario in RadMenu control.

    Regards,
    Plamen
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017