Firefox开发人员控制台中的XML解析错误 [英] XML Parsing Error in Firefox developer console

查看:376
本文介绍了Firefox开发人员控制台中的XML解析错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个jquery脚本,该脚本将数据发送到java servlet并根据servlet响应更新页面的内容.一切正常(该页面将按照我期望的值进行更新),但是我可以在firefox的开发人员控制台中看到以下错误:

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解析错误:语法错误位置: http://localhost:8080/servlet_url 行号1,列1

这是我的jQuery代码:

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>

推荐答案

似乎发生了此问题,因为我忘记了在servlet中设置响应内容类型.所以基本上这行代码:

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"); 

解决了问题.

这篇关于Firefox开发人员控制台中的XML解析错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆