RI工具库参考
1.异步等待对象可用,然后执行回调函数
controls的utils.js的文件里Utils.waitForReady
2.发请求
封装:
function getProxyJQuery(){
try{
return document.getElementById("welcome").contentWindow.$;//用于跨域,代理发送请求
}catch(e){
return null;
}
}
调用:
getProxyJQuery().ajax({
data:{xml:"<QueryMergeResult></QueryMergeResult>"},
url: url,
type:"POST",
success:function(R){
FF.alert(YIBUMSG.memooverlimit);
jslog(R);
},
timeout:30000
});
getProxyJQuery().post(requestUrl, { xml: requestBody }, function(response) {
var doc = getXmlDoc(response);
if (doc) {
var obj = xml2json(doc.documentElement, { AddLastContactsResp: { type: "simple"} });
if (obj && obj.ResultCode == "0") {
Contacts.addLastestContactsToCache(items);
Contacts.init("email", window);
}
}
});
getProxyJQuery().get(url, function(response) {
try {
var doc = getXmlDoc(response);
var obj = xml2json(doc.documentElement,{ AddrConfig: { type: "simple"} });
if (obj) {
Contacts.data.config = obj;
if (callback) callback({ success: true, tag: obj });
} else {
throw "获取失败";
}
} catch (e) {
if (callback) callback({ success: false });
}
});
3.xml字符串得到xml对象
Utils.getXmlDoc = function(xml) 或getXmlDoc