前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Ajax GET请求后台数据

Ajax GET请求后台数据

作者头像
week
发布2018-08-27 10:25:12
1.7K0
发布2018-08-27 10:25:12
举报
文章被收录于专栏:用户画像用户画像

一、目标

通过Ajax 请求后台数据

二、代码

1、前台ftl文件,通过URL请求后台数据,返回数据(Json格式)封装在data中

[#ftl]
[#include "/_inc/inc.ftl"]

<html>
   <head>
      <title>打印页面</title>
        [#include "/_inc/meta.ftl"]
    	[#include "/_inc/css.ftl"]
    	[#include "/_inc/link.ftl"]
   </head>

<body onload="getJudgeId()">
		<h3>打印进行中</h3>
</body>

<script type="text/javascript">
	 function getJudgeId()
	 { 
		$.get("${ctxPath}/common/waiting/task/usedcar/judge/id",{
 
		},function(data){
			
			if(data.status){
				var url="${ctxPath}/common/print/usedcar/judge/" + data.judgeId + "/0";
				printPreview(url);
			}
		});
	 }  

	 setInterval("getJudgeId()",1000*10);

</script>
</html> 

2、SpringMVC controller

	@RequestMapping(value = "common/waiting/task/usedcar/judge/id", method = RequestMethod.GET)
	public  @ResponseBody ModelAndView getShopInJSON() { 
		FastJsonJsonView view = new FastJsonJsonView();
		String judgeId = this.usedCarJudgePrintTaskService.getEarlyTaskJudgeIdByStatus("0");
		Boolean status = false;
		if(judgeId!=null&&judgeId.length()!=0){
			status = true;
			view.addStaticAttribute("status", status);
			view.addStaticAttribute("judgeId", judgeId);
		}else{
			view.addStaticAttribute("status", status);
		}
		return new ModelAndView(view);
	}		
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2015年08月19日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档