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

  • Home
  • SEARCH
  • 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 6605325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:16:14+00:00 2026-05-25T19:16:14+00:00

I am developing a web application and am using jQuery to provide a good

  • 0

I am developing a web application and am using jQuery to provide a good user interface for users. Therefore, I am using ajax requests and many jQuery functions.

If I disable JavaScript in the browser most of the function will not work because I am sending asynchronous ajax requests for many functions. But how can I handle this? Do I need to rewrite the code without using jQuery and ajax?

Find a below a sample button click event:

  $("#renameCategory").live('click', function (event) {
         if ($.trim($("#CategoryNewName").val()) == "") {
             alert("Please enter a category name");
             return;
         }
         var selectedCategory = $("#SelectedCategoryId").val();
         var newCategoryName = $("#CategoryNewName").val();
         var postData = { categoryId: selectedCategory, name: newCategoryName };
         $.ajax({
             type: "POST",
             url: '@Url.Action("UpdateCategoryName", "Category")',
             data: postData,
             dataType: "json",
             success: function (data) {
                 $('#' + selectedCategory).text(newCategoryName);
                 $("#selectedCategoryText").html(newCategoryName);
             },
             error: function () { alert('error') }
         });
     });

How can I handle this?

  • 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-25T19:16:15+00:00Added an answer on May 25, 2026 at 7:16 pm

    Ajax requests and jQuery will not work when the client has JavaScript disabled. The best way to make this work is to use the URL from the <a> tag href like so:

    <a href="@Url.Action("UpdateCategoryName", "Category")">Click Me!</a>
    
    $("#renameCategory").on('click', function (evt) {
            //To prevent the link from sending the default request
            //call preventDefault() on the jQuery event object
            evt.preventDefault();
            //
            if ($.trim($("#CategoryNewName").val()) == "") {
                 alert("Please enter a category name");
                 return;
             }
             //GET THE URL FOR THE AJAX REQUEST
             var actionUrl = $(this).attr('href');
             //
             var selectedCategory = $("#SelectedCategoryId").val();
             var newCategoryName = $("#CategoryNewName").val();
             var postData = { categoryId: selectedCategory, name: newCategoryName };
             $.ajax({
                 type: "POST",
                 url: actionUrl,
                 data: postData,
                 dataType: "json",
                 success: function (data) {
                     $('#' + selectedCategory).text(newCategoryName);
                     $("#selectedCategoryText").html(newCategoryName);
                 },
                 error: function () { alert('error') }
             });
         });
    

    You will also need to check for ajax requests in your Controller like below:

    public ActionResult UpdateCategoryName() {
        ...
    
        if(Request.IsAjaxRequest()) {
            return Json(yourData);
        }
    
        return View();
    }
    

    This way, if your user has JavaScript disabled, the link will function like a normal HTTP request. If the user has JavaScript enabled, then they will get the Ajax experience. This is called graceful degradation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a web application using ASP .NET MVC 1.0 and jQuery (including the
I'm using JQuery and Prototype in this web application that I'm developing. I'm looking
I am developing a web application, I need a modern photo gallary using ajax
I am developing a web application using backbonejs v 0.5.3 + jquery v 1.6.4.
we are developing a web application using MVC3 and Jquery. we have a situation
I'm in early (pre-coding) stages of developing a mobile web application using jQuery Mobile
i'm new to asp.net.. i'm developing a web application using asp.net a jquery. i
I'm developing a web app in asp.net mvc using jquery, the language of application
I am Developing a web application by using ASP.NET 3.5, jQuery and RadAjax Telerik
I am developing a web application with Zend Framework, and I am using JQuery

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.