Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6137691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:45:31+00:00 2026-05-23T17:45:31+00:00

I have html.actionlink in my asp.net MVC 3view and jquery ajax call on link

  • 0

I have html.actionlink in my asp.net MVC 3view and jquery ajax call on link click. In my action method suppose I have this:

 if (a == 2) //return ok 
                return Json(new { Error = "false", Message = "Everything ok" }, JsonRequestBehavior.AllowGet);
            else
                return Content("");

Ajax call is:

$(function () {
    $('#checkExists').click(function () {
        $.ajax({
            url: $('#checkExists').attr('href'),
            global: true,
            type: 'GET',           
            timeout: 5000,
            success: function (data) { //invoke when receive response from server                             

                if (data != null && data.Error != '') //return failed
                {
                    alert(data.Error);
                }
//                else {
//                    alert('error occurs 1');
//                    //action ok here
//                }
            },
          error: function (xhr, ajaxOptions, thrownError) {
              alert(xhr + ajaxOptions +  "Cannot connect to server to load data"); //sever is not available                 
            },
            complete: function () { //ajax done
                //alert('complete');
            }
        });
        return false;
    });

In case of else , ajax i called, how can I stop $.ajax call ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T17:45:32+00:00Added an answer on May 23, 2026 at 5:45 pm

    you have already made the ajax call there is no way you can undo it in your current scenario

    what you can do is send a doNothing response

     if (a == 2) //return ok 
                    return Json(new { Error = "false", Message = "Everything ok" }, JsonRequestBehavior.AllowGet);
                else
                    return Json(new { Message = "do nothing" }, JsonRequestBehavior.AllowGet);
    

    and in the ajax success callback

    success:function(data){
    if(data.Message==='do nothing'){
    // simply do nothing
    }
    }
    

    jsut as a side note you can cancel the ajax call before you have instantiated it see this SO answer Abort Ajax requests using jQuery

    update

    if (a == 2) //return ok 
                    return Json(new { Error = "false", Message = "Everything ok" }, JsonRequestBehavior.AllowGet);
                else
                    return Content("");
    

    and in the success callback

    success:function(data){
    if(!data.Message)
    //alert(data); //content will be shown
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question that has pretty much been asked here: asp.net mvc Html.ActionLink()
Possible Duplicate: HTML.ActionLink method In my ASP.NET MVC 3 application, I wish to generate
i have the following code in the asp.net mvc view if (isLoggedInUserAdmin) {%> <%=Html.ActionLink(View,
I have an ASP.Net MVC page where I want to use AJAX to update
Folks, I have ASP.NET MVC 3 Application and I have the following JQuery script
In ASP.NET MVC I see I have handy HTML helpers that I can use
I'm new to asp.net mvc. I have index method with parameter id : public
I have this part in asp.net MVC 3 view: <tr> <td>@Html.LabelFor(x => x.DateOfBirth, new
In my ASP.NET MVC controller classes I have action methods. In my views I
In ASP.NET MVC is there an equivalent of the Html.ActionLink helper for Img tags?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.