There was a problem with the ajax request

Attempting to make an ajax request in my SpringMVC project has been challenging.

$.ajax({
    contentType : 'application/json; charset=utf-8',
    type : 'get',
    url : 'order/get/'+i,
    dataType : 'json',
    data : {},
    success : function(result) {
        alert("Request successful!");
    },
    error : function(result, status, er) {
        alert("Error: "+result+" Status: "+status+" Error:"+er);
    }
});

@RequestMapping(value = "/order/get/{id}", method = RequestMethod.GET)
public ResponseEntity<Order> getOrder(
        @PathVariable("id") long id) {
    Order order = orderService.getOrderById(id);
    if (order == null) {
        new ResponseEntity<Order>(HttpStatus.NOT_FOUND);
    }
    return new ResponseEntity<Order>(order, HttpStatus.OK);
}

Despite the efforts, I am consistently encountering errors. The controller method is returning an object of 'order', but the ajax call keeps throwing 'GET net::ERR_CONNECTION_RESET' error. Why is this happening?

Answer №1

A dilemma arose when the Order entity was serialized to JSON with every attribute, even those marked as @ManyToOne. This led to an overly extensive serialization in JSON format, resulting in a massive response. To counteract this issue, specific attributes within the entity class Order had to be designated with the @JsonIgnore annotation. Once this adjustment was made, the error disappeared and the response processing resumed smoothly.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

angular: handling duplicates in ng-repeat

Here is the JSON data: streams = [{ id: 0, codec_type: 'video', content: '1920x1040 - H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10' }, { id: 1, codec_type: 'audio', content: '5.1(side) - cze - undefined' }, ...

Create a function that will repeatedly call itself at specified intervals, increment a variable, and update the class values of elements with an id matching the current value of the

I'm attempting to create a setup that cycles through different images <div id="img_box" class="shadow" onload="imgCycle(1)";> <img id="1" class='opaque imgbox selected' src="media/img ...

Customize the icon used for expanding and collapsing in AngularJS

I want to modify the icon (e.g., plus, minus) when clicking on an expand-collapse accordion. Currently, I am using the Font Awesome class for icons. While I know it can be easily achieved with jQuery, I'm wondering if there is a way to do this in Angu ...

Is it possible to easily upload files with TYPO3 Fluid using Ajax?

Currently, I'm facing a challenge in implementing an Ajax File Upload feature in TYPO3 Fluid. I am familiar with the Demo Extension created by Helmut Hummel on GitHub, but I find it to be too complex for my requirements and lacking a true ajax submiss ...

Node.js expressing caution about the use of backslashes in console logging statements

While this issue may not be considered crucial, I have observed an unexpected behavior when it comes to logging backslashes to the console. To verify the results, please try the following two examples in your terminal. I experimented with versions 0.10 an ...

Encountering timeout issues with Next.JS fetch and Axios requests on Vercel production environment

I've been encountering an issue where I am unable to fetch a specific JSON data as it times out and fails to receive a response on Vercel deploy. The JSON data I'm trying to fetch is only 18KB in size and the fetch request works perfectly fine in ...

Is it possible to utilize the "let" keyword in JavaScript as a way to prevent global-scope variables?

While working on a JavaScript test, I came across an interesting observation related to the let keyword. Take a look at this code snippet: let variable = "I am a variable"; console.log(window.variable); Surprisingly, when I tried to access the variable p ...

Is there a way for me to record the variable's name instead of its linked data?

Currently, I am developing a node.js program that monitors the prices of different currencies. While I can successfully retrieve the prices, I would like the program to also display the names of the currencies along with their prices. In the code snippet b ...

What causes the ongoing conflict between prototype and jquery?

I have researched how to effectively load both prototype and jQuery together, but the solutions I found did not resolve my issue. My current setup involves loading jQuery first, followed by this specific file: http:/music.glumbo.com/izzyFeedback.js, and t ...

The smooth transition of my collapsible item is compromised when closing, causing the bottom border to abruptly jump to the top

Recently, I implemented a collapsible feature using React and it's functioning well. However, one issue I encountered is that when the collapsible div closes, it doesn't smoothly collapse with the border bottom moving up as smoothly as it opens. ...

Retrieve the value of an object from a string and make a comparison

var siteList = {}; var siteInfo = []; var part_str = '[{"part":"00000PD","partSupplier":"DELL"}]'; var part = part_str.substring(1,part_str.length-1); eval('var partobj='+part ); console.log(par ...

Managing Modules at Runtime in Electron and Typescript: Best Practices to Ensure Smooth Operation

Creating an Electron application using Typescript has led to a specific project structure upon compilation: dist html index.html scripts ApplicationView.js ApplicationViewModel.js The index.html file includes the following script tag: <script ...

Incorporating a JavaScript advertisement zone within a PHP function

Currently in the PHP template, I am trying to embed a JavaScript ad zone inside a function in order to have control over each page's ad placement. Here is what I have: <?php if(is_page('welcome-president')) { oiopub_b ...

The first item in Swiper is incorrectly displayed after the initial cycle, even though the data is accurate

Currently, I am incorporating the slider functionality in Vue using the Swiper framework. Although everything seems to be functioning properly, there is a minor issue that arises when filtering the data and completing the first cycle after scrolling. The f ...

Using socket.io-client in Angular 4: A Step-by-Step Guide

I am attempting to establish a connection between my server side, which is PHP Laravel with Echo WebSocket, and Angular 4. I have attempted to use both ng2-socket-io via npm and laravel-echo via npm, but unfortunately neither were successful. If anyone h ...

Can we tap into the algorithm of curveMonotoneX in d3-shape?

I'm currently using curveMonotoneX to draw a line in d3 import React from 'react'; import { line, curveMonotoneX } from 'd3-shape'; export default function GradientLine(props) { const { points } = props; const lineGenerator ...

What is the best way to display a unique image in a div based on the size of the

Being new to web design, I have a question about creating a webpage with a large image in the center like on GitHub's Windows page. How can I work with the image inside that particular div or area based on different screen sizes? Is it possible to mak ...

Choosing the perfect item with the help of a material's GridList

I've developed a react-mobx application using Material-UI, and the code structure is similar to this: render() { // defining some constants return ( <div> <img src={selectedPhoto} alt={'image title'} /> < ...

Does the "onevent" option get disregarded for jsf.ajax.request in JSF

In my attempt to develop an interactive chat web application using Java EE 7, I am specifically utilizing JSF 2.2 with ajax. The concept involves having a slow pending asynchronous ajax request waiting on the server for each unique client. When a new mess ...

Error loading custom Javascript in MVC 4 view during the first page load

I'm working on an MVC 4 application that utilizes jQuery Mobile. I have my own .JS file where all the functionality is stored. However, when I navigate to a specific view and check the page source, I notice that all scripts files are loaded except fo ...