Skip to main content

Mini Project: One URL, Page for Browsers and JSON for AJAX

Learn Mini Project: One URL, Page for Browsers and JSON for AJAX (Spring MVC + AJAX, Spring MVC) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Mini Real-Time Project: One URL, Page for Browsers and JSON for AJAX Problem A search box updates the result list without reloading the page (AJAX). The same endpoint must still work as a normal page for browsers without JavaScript, and return proper errors to the JavaScript code. Requirements Detect an AJAX call (X-Requested-With header or Accept: application/json). Return JSON for AJAX and an HTML fragment/page for normal requests from the same URL. Return 204 when a search has no results, and 400 with a JSON error for bad input. Show the JavaScript call that would use it. Concepts Used AJAX...

More lessons in Spring MVC + AJAX