gpt4 book ai didi

java - 接收错误: "200": "parsererror": SyntaxError: "Unexpected end of input" during jquery ajax call

转载 作者:行者123 更新时间:2023-12-01 14:52:10 27 4
gpt4 key购买 nike

这是我的代码:

$.ajax({
url: "MyServlet",
dataType: "json",
data: data,
type: "post",
cache: false
}).done(function (data) {
alert('hello');
}).fail(function (XMLHttpRequest, textStatus, errorThrown) {
alert('error: ' + XMLHttpRequest.status + ": " + XMLHttpRequest.responseText + ": " + textStatus + ": " + errorThrown);
});

我收到:“错误:200:解析器错误:语法错误:输入意外结束”

我不明白为什么。有什么帮助吗?

我的 servlet 基本上返回以下内容:

PrintWriter out = response.getWriter();
JSONObject json = new JSONObject();
json.put("test", "hello servlet");
out.print(json);
out.close();

最佳答案

我已经弄清楚了。我没有正确关闭 servlet 中的输出流,导致返回错误的 json 数据。

关于java - 接收错误: "200": "parsererror": SyntaxError: "Unexpected end of input" during jquery ajax call,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14732618/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com