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 6565937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:09:24+00:00 2026-05-25T14:09:24+00:00

I am submitting a form using ajax and what I need to do is

  • 0

I am submitting a form using ajax and what I need to do is reset the form once a successful submission has been made. However, what is happening is that the form is being cleared once the user submits. I have tried to place the code in Success, Complete but it keeps resetting even if a user receives the error message. I only need to reset after the else statement. ie; The user receives the success message. How can I correct this. Thanks

$.ajax({
      type: "POST",
      url: "boxrtrvajax.php",
      cache: false,
      data: send,
      success: function (data) {
      if (data == 'No data'){
      $('#brtv-result').addClass("result_msg").html('Please fill in all fields');
      }

      else

      //location.reload(true);
      $('#brtv-result').addClass("result_msg").html("You have successfully retrieved: "+data).fadeIn(4000).delay(4000).fadeOut(4000);
      $("#BRV-brtrv-slider").val(0).slider("refresh");
      $("input[type='radio']").attr("checked",false).checkboxradio("refresh");
      var myselect = $("select#BRV-brtrv-department");
      myselect[0].selectedIndex = 0;
      myselect.selectmenu("refresh");
      var myselect = $("select#BRV-brtrv-address");
      myselect[0].selectedIndex = 0;
      myselect.selectmenu("refresh");
      },

      error:function (xhr, ajaxOptions, thrownError){
      jAlert('There was an exception thrown somewhere');
      alert(xhr.status);
      alert(thrownError);
     }
   });
  • 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-25T14:09:25+00:00Added an answer on May 25, 2026 at 2:09 pm

    You dont have brackets around your else statement so it completes the code no matter what

     if (data == 'No data')
          $('#brtv-result').addClass("result_msg").html('Please fill in all fields');
     else
     {
          //location.reload(true);
          $('#brtv-result').addClass("result_msg").html("You have successfully retrieved: "+data).fadeIn(4000).delay(4000).fadeOut(4000);
          $("#BRV-brtrv-slider").val(0).slider("refresh");
          $("input[type='radio']").attr("checked",false).checkboxradio("refresh");
          var myselect = $("select#BRV-brtrv-department");
          myselect[0].selectedIndex = 0;
          myselect.selectmenu("refresh");
          var myselect = $("select#BRV-brtrv-address");
          myselect[0].selectedIndex = 0;
          myselect.selectmenu("refresh");
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form I am submitting via AJAX (using prototype and the built-in
I'm uploading a file using jQuery through Ajax. I'm submitting some form elements also,
So I have a form and I'm submitting the form through ajax using jquery
I am using Ajax validation extender with the ListBox. On submitting the form, the
I have a textarea and am submitting the form it is in using AJAX
I am submitting a form in spring g MVC using ajax. The form is
i m using asp.net mvc2 and i m submitting a form through ajax using
I have a form I am submitting using jQuery's ajaxSubmit function from the Forms
Upon submitting this form on my site. It send me to a page that
I have a form that contains a bunch of checkboxes. Before submitting the form,

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.