<
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
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:
<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
$(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
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
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.
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
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
}
});
})
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