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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:11:03+00:00 2026-05-26T18:11:03+00:00

I have some web application that uses jQuery to send AJAX requests to server.

  • 0

I have some web application that uses jQuery to send AJAX requests to server. One of the methods (in controller) returns a ModelAndView object that can be a html code or JSON object – depends on errors existing. The input parameters of thid method is JSON array (form).
The method definition:

@RequestMapping(value = "/generate", method = RequestMethod.POST, headers = BaseController.AJAX_HEADER)
public ModelAndView generate(@RequestBody HandlingReportForm form, HttpServletResponse response) {...}

The jQuery method looks like:

jQuery.ajax({
    'type': 'POST',
    'url': url,
    'contentType': 'application/json',
    'data': JSON.stringify(data),
    'dataType': 'json',
    'success': callback,
    error : function(jqXHR, textStatus, errorThrown) {
        alert(errorThrown);
    },
    complete : function(jqXHR, textStatus) {
        alert(textStatus);
    }
});

There is no problem when server returns a JSON array. The problem comes when server’s response is html. I receive a “parseerror” exception. I suppose that jQuery trying to parse the response string to JSON. AM I right?
How can I disable that automatic parsing? Is there another way to implement such universal method?

Thank you
Thank you

  • 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-26T18:11:04+00:00Added an answer on May 26, 2026 at 6:11 pm

    The dataType has been mentioned as json, hence JQuery would try to interpret the response as an json object.

    JQuery Ajax documentation –

    dataType – “json”: Evaluates the response as JSON and returns a JavaScript object. In jQuery 1.4 the JSON data is parsed in a strict manner; any malformed JSON is rejected and a parse error is thrown. (See json.org for more information on proper JSON formatting.)

    Its better to return a single response format.

    You can also exclude the dataType argument.
    If none is specified, jQuery will try to infer it based on the MIME type of the response (an XML MIME type will yield XML, in 1.4 JSON will yield a JavaScript object, in 1.4 script will execute the script, and anything else will be returned as a string).

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

Sidebar

Related Questions

I have a web application that uses jQuery to load some sound effect on
I have a winform application that uses some referenced web services to get data.
We have developed a .NET web application that uses SQL Server as a backend.
I have a web application that uses Jasper Reports. I want to tweak some
I need to debug a web application that uses jQuery to do some fairly
I have a web application that uses the current version of JQuery that needs
I have a web application that allows a user to search on some criteria,
I have a web application that I want to run some system tests on,
I have a database for a web application that is home to some personal
We have built a web application that accepts SOAP messages, does some processing, calls

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.