前台先写好ajax

 

<script>
$.ajax({
url : "newsservlet",//请求地址
dataType : "json",//数据格式 
type : "post",//请求方式
async : true,//是否异步请求
success : function(data) {
//data是服务器返回数据
alert(data);
},
});
</script>

 

后台

        PrintWriter out=response.getWriter();
        String a="aaa";
        out.write(a.toString());
        

页面显示

【Ajax】前台接收后台传输的数据

 


 

相关文章:

  • 2022-12-23
  • 2021-09-15
  • 2022-12-23
  • 2022-12-23
  • 2021-11-04
  • 2021-08-15
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-12
  • 2022-12-23
  • 2022-12-23
  • 2021-07-16
  • 2021-12-16
  • 2021-11-07
相关资源
相似解决方案