12

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>

1 Answer 1

14

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.