<div id="newsInfo">正在加载...</div>

1、JSON格式:

[{'R': '1','NOTI_ID': '9','NOTI_TITLE': '我的博客','NOTI_CONTENT': '博客园博客园博客园博客园','NOTI_CREATETIME': '2010/9/3022: 46: 16','NOTI_CLICK': '17005','SHENHE_DATE': '2014/5/158: 58: 03','USER_NAME': '管理员'}]

function getinfo()
{
var par=zy_parse();
var url="http://XXX/webservice.asmx/getBSZNInfo?id="+par.id;
$.getJSON(url,function(data)
{
var strResult =data.replace('<string xmlns="http://tempuri.org/">','');
strResult=strResult.replace('<?xml version="1.0" encoding="utf-8"?>','');
strResult=strResult.replace('</string>','');
//alert(strResult);
var str=eval(strResult);
var temp='<div class="c-gra uinn tx-c ulev1">${NEWS_TITLE}</div>'
+'<div class="ubb b-gra c-gra uinn tx-c ulev-1">作者:${USER_NAME} 更新时间:${cb:NEWS_CREATETIME}</div>'
+'<div class="c-gra uinn">'
+'<div class="">${NEWS_CONTENT}</div></div>';
var s=zy_tmpl(temp,str,zy_tmpl_count(str),function(a,b){
switch(b[1]){
case 'NEWS_CREATETIME':
var dt = new Date(a['NEWS_CREATETIME']).toLocaleDateString();
return dt;
}
});
$$("newsInfo").innerHTML=s;
},"text",
function(e)
{ },"GET","",true
);
}

2、自定义格式(此方式可以解决因包含HTML符号在JSON中不显示的问题):

[{R,1|NOTI_ID,9|NOTI_TITLE,我的博客|NOTI_CONTENT,博客园博客园博客园博客园|NOTI_CREATETIME,2010/9/30 22:46:16|NOTI_CLICK,17005|SHENHE_DATE,2014/5/15 8:58:03|USER_NAME,管理员}]

function httpReqGet(){
var httpId = 999;
uexXmlHttpMgr.onData = function(inOpCode,inStatus,inResult){
if(inStatus == 1){
uexXmlHttpMgr.close(httpId);
uexLog.sendLog('[GET] '+inResult);
var strResult =inResult.replace('<string xmlns="http://tempuri.org/">','');
strResult=strResult.replace('<?xml version="1.0" encoding="utf-8"?>','');
strResult=strResult.replace('</string>','');
var temp='<div class="c-gra uinn tx-c ulev1">{NEWS_TITLE}</div>'
+'<div class="ubb b-gra c-gra uinn tx-c ulev-1">作者:{USER_NAME} 更新时间:{NEWS_CREATETIME}</div>'
+'<div class="c-gra uinn">'
+'<div class="s-content-img">{NEWS_CONTENT}</div></div>';
var arr=new Array();
arr = strResult.split("|");
for (var i=0; i < arr.length; i++) {
var brr=new Array();
brr = arr[i].split(",");
temp=temp.replace("{"+brr[0]+"}",brr[1]);
}
temp=temp.replace(/&lt;/g,"<");
temp=temp.replace(/&gt;/g,">");
temp=temp.replace(/&nbsp;/g," ");
temp=temp.replace(/&amp;#8220;/g,"“");
temp=temp.replace(/&amp;#8221;/g,"”");
temp=temp.replace(/&amp;nbsp;/g," ");
temp=temp.replace("/uploads","http://XXX/uploads");
$$("newsInfo").innerHTML=temp;
//alert(temp);
}
}
//开始一个跨域异步请求
var par=zy_parse();
uexXmlHttpMgr.open(httpId,'get','http://XXX/webservice.asmx/getBSZNInfo?id='+par.id,30000);
uexXmlHttpMgr.send(httpId);
}

AppCan中两种获取信息的方法的更多相关文章

  1. Hibernate中两种获取Session的方式

    转自:https://www.jb51.net/article/130309.htm Session:是应用程序与数据库之间的一个会话,是hibernate运作的中心,持久层操作的基础.对象的生命周期 ...

  2. ajax请求中 两种csrftoken的发送方法

    通过ajax的方式发送两个数据进行加法运算 html页面 <body> <h3>index页面 </h3> <input type="text&qu ...

  3. objective-C 中两种实现动画的方法

    第一种方法: [UIView beginAnimations:@"Curl"context:nil];//动画开始 [UIView setAnimationDuration:1.2 ...

  4. objective-C 中两种实现动画的方法(转)

     转发自:http://wayne173.iteye.com/blog/1250232 第一种方法: [UIView beginAnimations:@"Curl"context: ...

  5. [TestNG] Eclipse/STS中两种安装TestNG的方法

    Two Ways To Install TestNG in Eclipse/STS Today I install the newest Sprint Tool Suite and want to i ...

  6. Python 两种获取文件大小的方法

    import os r=os.path.getsize("/root/catbird1.stl") f=open("/root/catbird1.stl",&q ...

  7. php 两种获取分类树的方法

    php 两种获取分类树的方法 1. /** * 获取分类树 * @param array $array 数据源 * @param int $pid 父级ID * @param int $level 分 ...

  8. 接口测试中GET和POST两种基本HTTP请求方法的区别

    面试时,可以回答(一般答前4条就行): GET参数通过url传递,POST放在request body中 GET请求在url中传递的参数是有长度限制的,而POST没有 GET比POST更不安全,因为参 ...

  9. JAVA 中两种判断输入的是否是数字的方法__正则化_

    JAVA 中两种判断输入的是否是数字的方法 package t0806; import java.io.*; import java.util.regex.*; public class zhengz ...

随机推荐

  1. http://www.ibm.com/developerworks/cn/opensource/os-cn-cas/

    http://www.ibm.com/developerworks/cn/opensource/os-cn-cas/

  2. Php使用sqlite

    php sqlite文档:http://php.net/manual/en/book.sqlite.php sql:http://www.php100.com/html/webkaifa/PHP/PH ...

  3. CCS3.3之DM642开发环境建立

    使用的仿真器是SEED-XDSUSB2.0/5V. 之前用的是CCS2.2,换成了CCS3.3的. 1.安装CCS3.3.38.在我安装完后,并没有急着升级,升级的程序是SR12_CCS_v3.3_S ...

  4. Centos6.5 安装Vim7.4

    系统本身会带Vim7.2都版本,其实也够用,强迫症患者可以按以下操作升级成Vim7.4: (1)切换到root权限 (2)卸载 rpm -qa | grep vim yum remove vim vi ...

  5. JIRA Cannot Start Due to 'unable to clean the cache directory: /opt/jira/plugins/.osgi-plugins/felix'

    Symptoms After restarting JIRA, the following error appeared: JIRA Startup Failed You cannot access ...

  6. java 全角半角转换函数

    /** * 半角转全角 * @param input String. * @return 全角字符串. */ public static String ToSBC(String input) { ch ...

  7. HDU-1716 排列2 (DFS)

    排列2 Time Limit : 1000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Submissio ...

  8. 使用Notify 和 wait ,使用Linklist实现生产者消费者问题

    ref:http://www.cnblogs.com/happyPawpaw/archive/2013/01/18/2865957.html 注释很清楚的, import java.util.Link ...

  9. jQuery技术内幕预览版.pdf2

    第二章 构造jQuery对象 jQuery对象是一个类数组对象,含有连续的整型属性.length属性和大量的jQuery方法,$()是jQuery()的缩写 构造函数jQuery() 如果调用构造函数 ...

  10. java使用batik转换svg文件

    svg是一种矢量图片格式,用来保存高保真的图片.我们可以用编辑器打开svg,我们可以看到svg文件其实就是一个xml文件,这种文件浏览器也可以识别.因此要查看svg用现成的浏览器就可以了.值得庆幸的是 ...