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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:47:17+00:00 2026-05-28T17:47:17+00:00

My index.jsp page, load my form with this line of code : $(‘#box’).load(‘/Edit_Data.jsp?id=’ +

  • 0

My index.jsp page, load my form with this line of code :

 $('#box').load('/Edit_Data.jsp?id=' + myID);

Then, I can correctly edit the data presents in the form. When I’ve finished, I click on a button that triggers this function :

function save() {
  $.ajax({
    type: 'POST',
  cache: false,
     url: '/Edit_data',
    data: $('form[name="formData"]').serialize(),
  complete : function(jqXHR,textStatus) {
    alert("complete " + jqXHR.responseText );
    },
  error: function(jqXHR,textStatus){
        alert("status " + textStatus + ", response :" + jqXHR.responseText);
     }
   });

}

and my java servlet for the path “/Edit_data”, return this :

  resp.setCharacterEncoding("UTF-8");
  resp.setContentType("text/xml");
  String xml = "<report><error_msg></error_msg></report>";
  resp.getWriter().println(xml);

The behavior after I clicked on the button is :

  1. The request is correctly sent
  2. I receive the error alert message : status error, response :
  3. Then, I receive the complete message :complete (the responseText is null)
  4. Finally, it reloads my index.jsp page with a Get request with the parameters that I sent to the servlet. Like that : http://localhost:8888/index.jsp?name=test&firstname=test

My problem is : why after the ajax request has been done, the index.jsp page is reloaded. The correct behavior should be : after the request, nothing sould be done because I handle the complete function

One clue should be the error message returned by the servlet, but I can’t see the full content of the error so I don’t understand what triggers the error…

One other important clue, I only have this problem with firefox and chrome. It works correctly for IE.

Could you help me to solve that?

Thank you very much,

Bat

  • 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-28T17:47:18+00:00Added an answer on May 28, 2026 at 5:47 pm

    Ajax means asynchronous request…
    It should not reload ideally,If you didn’t do any mistake.
    Well, you can use return false;
    Or on calling ajax function onclick="return AjaxFunction(); For your case it might be : onclick="return save();

    Hope this will solve your issue.

    Cheers!

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

Sidebar

Related Questions

I has a jsp page (index.jsp) with a form with two text fileds username
I have Vector declared in index.jsp page like this: <%! Vector vNumbers = new
I have this simple JSP page in Eclipse and the first line in the
I have my GWT code in an index.jsp page, and when I view the
I have the following code: index.jsp: <form name=f action=db/ajoutConducteur.jsp method=post> <input type=text pattern=\d{8} required
In a JSP page(index.jsp): ${requestContext.requestURL} is the URL just shows the expression itself. It
My index.html page for my project needs some Ruby code so I need to
Help me ..my page index is not working in visual studio. my page load
i am using primefaces library this is my jsp page source: <%@taglib uri=http://primefaces.prime.com.tr/ui prefix=p%>
using Struts2, I successfully load an external URL inside a jsp page using an

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.