WEB开发网
开发学院手机开发Symbian 开发 Symbian WRT中使用JS自动将XML、JSON转换成为对象... 阅读

Symbian WRT中使用JS自动将XML、JSON转换成为对象

 2010-08-30 00:03:00 来源:WEB开发网   
核心提示:function ajaxFetch(url, param, callback,exceptionCallBack, isXML) {var req = new Ajax();req.onreadystatechange = function() {if (req.readyState == 4 && req.stat

function ajaxFetch(url, param, callback,exceptionCallBack, isXML) {

var req = new Ajax();

req.onreadystatechange = function() {

if (req.readyState == 4 && req.status == 200) {

if (!isXML && req.responseText != null) {

callback(req.responseText);

} else if (isXML && req.responseXML != null) {

callback(req.responseXML);

} else {

callback(null);

}

} else if (req.readyState == 4 && req.status != 200) {

if(exceptionCallBack!=null&&exceptionCallBack!=undefined)

exceptionCallBack();

}

}

var fullURL = url;

if (fullURL.indexOf("?") == -1) {

fullURL += "?";

} else {

fullURL += "&";

}

fullURL += "timestamp=" + (new Date().getTime());

fullURL += "&" + param;

req.open("GET", fullURL, true);

req.send(null);

}

ProcessData.js - 用于处理数据并且进行回调

Js代码

/**

* 构造方法

* @param {Object} Url xml JSON地址

* @param {Object} parentNode 父节点,比如要把转成对象,此参数就是item

* @param {Object} options

* @param {Object} processDataFunction ???象弈?完成后需要整用的方法

*/

function ProcessData(Url, parentNode, options, processDataFunction){

this.URL = xmlUrl;

this.parentNode = parentNode;

this.options = options;

this.processDataFunction = processDataFunction;

selfProcessData = this;

}

ProcessData.prototype = new Object();

ProcessData.prototype.URL;

ProcessData.prototype.options;

ProcessData.prototype.parentNode;

ProcessData.prototype.processDataFunction;

ProcessData.prototype.dataArray;

上一页  1 2 3 4 5 6 7  下一页

Tags:Symbian WRT 使用

编辑录入:coldstar [复制链接] [打 印]
赞助商链接