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

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

8 Answers 327 Views
SearchBox
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 14 Nov 2013, 11:12 AM
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?

 


8 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 18 Nov 2013, 09:23 AM
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.
0
Tarek
Top achievements
Rank 1
answered on 06 Jan 2014, 09:50 AM
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
0
Plamen
Telerik team
answered on 07 Jan 2014, 12:20 PM
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.
0
Andrew
Top achievements
Rank 1
answered on 17 May 2016, 07:56 AM

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.

0
Plamen
Telerik team
answered on 20 May 2016, 06:56 AM
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.
0
Andrew
Top achievements
Rank 1
answered on 20 May 2016, 07:05 AM
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...
0
Andrew
Top achievements
Rank 1
answered on 18 Jul 2016, 09:27 AM

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
        }
    });
})

0
Plamen
Telerik team
answered on 21 Jul 2016, 08:19 AM
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.
Tags
SearchBox
Asked by
Steve
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Tarek
Top achievements
Rank 1
Andrew
Top achievements
Rank 1
Share this question
or