0
我有以下ajax代码,我想在html页面上打印值。从ajax打印返回值调用
var val = $.ajax({
type: "post",
url: "count.jsp",
data: "",
cache: false,
success: function(str)
{
return str;
}
});
alert (val);
我想用val打印。下面的代码是count.jsp
。
ResultSet rs=pst.executeQuery();
if(rs.next())
{
val=rs.getInt(1);
}
out.println(val);
如何在页面上打印val?
嗨,谢谢,给我输出。但是,当试图显示像成功的元素:function(str) {\t \t \t \t \t //document.write(str); \t \t \t的document.getElementById( “测试”)。值= STR}} 上itsnot
– zdhim'的document.getElementById( “测试”)。值设置值=从成功处理程序内str'应,如果你工作得很好有'id =“test”'的div。不要在ajax调用中使用'document.write()',因为这会清除整个文档。 – jfriend00
现在工作,但