验证码

<img src="<{:url('publics/verify','id=login')}>"  onclick="this.src='{:url('publics/verify','id=login')}'">

json格式化显示

/**
* 格式化显示json格式数据
*/
function formatJson(json, options) {
var reg = null,
formatted = '',
pad = 0,
PADDING = ' ';
options = options || {};
options.newlineAfterColonIfBeforeBraceOrBracket = (options.newlineAfterColonIfBeforeBraceOrBracket === true) ? true : false;
options.spaceAfterColon = (options.spaceAfterColon === false) ? false : true;
if (typeof json !== 'string') {
json = JSON.stringify(json);
} else {
json = JSON.parse(json);
json = JSON.stringify(json);
}
reg = /([\{\}])/g;
json = json.replace(reg, '\r\n$1\r\n');
reg = /([\[\]])/g;
json = json.replace(reg, '\r\n$1\r\n');
reg = /(\,)/g;
json = json.replace(reg, '$1\r\n');
reg = /(\r\n\r\n)/g;
json = json.replace(reg, '\r\n');
reg = /\r\n\,/g;
json = json.replace(reg, ',');
if (!options.newlineAfterColonIfBeforeBraceOrBracket) {
reg = /\:\r\n\{/g;
json = json.replace(reg, ':{');
reg = /\:\r\n\[/g;
json = json.replace(reg, ':[');
}
if (options.spaceAfterColon) {
reg = /\:/g;
json = json.replace(reg, ': ');
}
$.each(json.split('\r\n'), function(index, node) {
var i = 0,
indent = 0,
padding = '';
if (node.match(/\{$/) || node.match(/\[$/)) {
indent = 1;
} else if (node.match(/\}/) || node.match(/\]/)) {
if (pad !== 0) {
pad -= 1;
}
} else {
indent = 0;
}
for (i = 0; i < pad; i++) {
padding += PADDING;
}
formatted += padding + node + '\r\n';
pad += indent;
});
return formatted;
};

  

最新文章

  1. Java多线程基础知识篇
  2. SQL Server 2008数据库日志收缩
  3. Android IOS WebRTC 音视频开发总结(八十一)-- WebRTC靠谱吗?有没有适合的SDK推荐?
  4. [Spring MVC] - @ModelAttribute使用
  5. js实现右侧的分享效果
  6. 简单修改 MySQL 的 root 账号密码
  7. unix network programming(3rd)Vol.1 [第1章]《读书笔记系列》
  8. Render Texture的使用(截取rendertexture的一帧到Texture2D)
  9. win2003+IIS6+PHP5.3.8+MSSQL2008的安装配置
  10. 【转】CTS tests 4.2_r4
  11. gamma
  12. eclipse代码提示配置
  13. linux shell 找端口号及对应的进程
  14. Js之on与addEventListener的使用与两者的不同
  15. require.js模块化写法
  16. python时间模块time
  17. PL-SLAM
  18. java运行报错:nested exception is java.lang.NoSuchFieldError: INSTANCE,但使用@Test测试是好的
  19. 【ORACLE】oracle数据库用户密码复杂度配置
  20. 用EXCEL的VBA将PHPCMS的备份文件转换成HTML的一次尝试

热门文章

  1. 【教程】简易CDQ分治教程&amp;学习笔记
  2. WPF仿百度Echarts人口迁移图
  3. SQL Server数据库设计规范
  4. NPOI操作EXCEL(六)——矩阵类表头EXCEL模板的解析
  5. 常用Linux命令
  6. NIO服务器
  7. 1229【MySQL】性能优化之 Index Condition Pushdown
  8. 千万级高并发负载均衡软件HAproxy
  9. bzoj2243
  10. Ubuntu14.04解决远程root-ssh拒绝登录