I have a jquery scripts which sends data to a java servlet and updates the content of the page basing on the servlet response. Everything works (the page gets updated with the values as I was expecting), but I can see in the developer console in firefox the following error:
XML Parsing Error: syntax error Location: http://localhost:8080/servlet_url Line Number 1, Column 1
This is my jQuery code:
<script src="http://code.jquery.com/jquery-1.10.2.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$.post('servlet', {
filepath : '${file}'},
function(responseText){
$('#div_id').text(responseText);
});
});
</script>
It seems that the issue occurred because I forgot to set the response content type in the servlet. So basically this line of code:
response.setContentType("text/plain");
solved the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With