【发布时间】:2014-10-05 13:56:04
【问题描述】:
我有来自 Jquery ajax 的 restful webservices 调用并在 json 对象中获取响应。 jQuery HTML:
$.ajax({
url: "mcrs/object/api/Lighting",
type: "POST",
traditional: true,
dataType: "json",
contentType: "application/x-www-form-urlencoded",
async: "false",
data:JSON.stringify(postdata),
success: function (ResData) {
},
error: function (error, data) {
console.log(error);
}
});
}
});
并在java中为restful webservices编写响应对象
@POST
@Path("api/{subsystem}")
@Produces("application/json")
public Response changeStatus(@PathParam("subsystem") String subsystem,
/*@FormParam("result")*/ String result) {
}
我得到了下面的回复,这是正确的
changeStatus:88 - 响应 OutboundJaxrsResponse{status=200, reason=OK, hasEntity=true, closed=false, buffered=false}
根据响应需要更新标签标签中的值是开/关的状态。 str = '
状态:' + '' + onoffStat + '';
如何在 ajax 中实现这一点,并希望每 2 秒刷新一次 div 标签。
请帮帮我。
【问题讨论】:
-
您要更新的“状态”是什么?
标签: java javascript jquery ajax json