@RequestMapping("/notification")
@ResponseBody
public String countNotification(HttpServletRequest request) throws Exception {
Notify not = Notify.get();
int notification = 4;
not.put("size", notification);
return not.toString();
}
var notificationCount = function() {
jQuery('.js-countnot').load('notification', function(response, status, xhr) {
var resp = JSON.parse(response);
$( "#containera").text( resp.size);
}
});
}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery.data demo</title>
<style>
div {
color: blue;
}
span {
color: red;
}
</style>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<div id="container">
<img src="notification.png" alt="" />
<div id="containera">
</div>
</div>
<script>
notificationCount();
</script>
</body>
</html>
No comments:
Post a Comment