Edit this page

Cancel AJAX Request

You can cancel an AJAX request in the OnRequestStart client-side event handler of your RadAjaxManager/RadAjaxPanel.Calling set_cancel(true) prevents the request from continuing.

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type='text/javascript'>
                function OnRequestStart(ajaxPanel, eventArgs) {
                    var eventTarget = eventArgs.get_eventTarget();
                    if (eventTarget == "<%= Button1.UniqueID %>") {
                        if (!CheckZipCode()) {
                            eventArgs.set_enableAjax(false); // cancel the ajax request

                function CheckZipCode() {
                    var zipCode = $get('<%= TextBox1.ClientID %>').value;
                    if (zipCode.length != 5) {
                        alert('Please enter a valid 5 digit postal code!');
                        return false;
                    else {
                        var fiveDigitCheckRE = /^\d{5}$/ //regular expression for checking a 5 digit number
                        if (zipCode.search(fiveDigitCheckRE) == -1) {
                            alert("Only digits are allowed!");
                            return false;
                    return true;

See Also

Is this article helpful? No Yes
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article