Reputation: 21
I am calling API to return a JSON
with all needed objects (notes):
$( document ).ready(function() {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState == XMLHttpRequest.DONE) {
var response = xhr.responseText;
//do stuff with response
}
xhr.open('GET', 'http://mydomain:8080/notes/all', true);
xhr.send(null);
});
HTTP request:
@RequestMapping(value = {"/all"}, method = RequestMethod.GET, produces = "application/json")
public @ResponseBody List<Note> getAllNotes() {
return noteService.getAllNotes();
}
When I run locally on Mac, everything works. My Response header has Content-Type: application/java, and Request accepts it.
However, when I upload my .war to Ubuntu 16.04
server, Request header's Content-Type changes to txt/html
, and I get
404 Page Not Found
.
I am using tomcat8.5.5
on both machines.
How do I specify/change the Request Header Content-Type?
Images of headers: running on remote and local
Upvotes: 0
Views: 1157
Reputation: 21
I noticed that I had <script src="noteAPI.js"></script>
declaration in BOTH index.html and notes.html. I have removed this declaration from index.html and it worked!
Upvotes: 1