当我在<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<display-name>JerseyAuthentication</display-name>
<servlet>
<servlet-name>Application</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>org.jersey.media.type</param-value>
</init-param>
<!-- <init-param>
<param-name>jersey.config.server.provider.classnames</param-name>
<param-value>org.glassfish.jersey.jackson.JacksonFeature,org.glassfish.jersey.jackson.JacksonBinder</param-value>
</init-param> -->
</servlet>
<servlet-mapping>
<servlet-name>Application</servlet-name>
<url-pattern>/service/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>login.html</welcome-file>
</welcome-file-list>
</web-app>
之外拨打$("#editor1").val(data);
时,数据显示在textarea的文本字段中。当我尝试将它放在jQuery.ajax的成功函数中时,不会显示任何内容。
有人可以回答为什么以及如何更改它以便工作?
以下是代码:
jQuery.ajax
这恰恰相反:
<script>
function getFromServer(id){
var data = {"id" : id};
jQuery.ajax({
url:"http://localhost/amsprojektgit/amsprojekt/admin/web/ajaxg/"+id,
method: "post",
data: data,
success: function(data) {
$("#editor1").val(data);
},
error: function(){
alert("Wystąpił nieoczekiwany problem!");
}
});
}
</script>
答案 0 :(得分:0)
试试此代码
<script>
function getFromServer(id){
var data = {"id" : id};
jQuery.ajax({
url:"http://localhost/amsprojektgit/amsprojekt/admin/web/ajaxg/"+id,
method: "post",
data: data,
success: function(responsedata) {
$("#editor1").val(responsedata);
},
error: function(){
alert("Wystąpił nieoczekiwany problem!");
}
});
}
</script>
答案 1 :(得分:0)
确定。我解决了问题可能是我使用带有textarea的CKeditor进行文本编辑。正确的代码应该是:
function getFromServer(id){
var data = {"id" : id};
var a;
jQuery.ajax({
url: "http://localhost/amsprojektgit/amsprojekt/admin/web/ajaxg/"+id,
method: "get",
success: function(response) {
CKEDITOR.instances.editor1.setData(response);
},
error: function(){
alert("Wystąpił nieoczekiwany problem!");
}
});
}
无论如何,谢谢你的建议。