var jsonObj;
var xmlhttp = null;
function callAsync(url, callbackSuccess)
{
xmlhttp = new Ajax();
xmlhttp.open("GET", url, true);
xmlhttp.onreadystatechange=function()
{
// readyState = 4 ; "complete"
if (xmlhttp.readyState==4)
{
// status = 200 ; "ok"
if(xmlhttp.status == 200)
{
uiManager.showNotification(1000, "ok", "Done");
/*
* Remove the substr "jsonFlickrApi(" from the responseText
*/
var text = xmlhttp.responseText;
text = text.substr(14, text.length-15);
// Create JSON Oject
jsonObj = eval('(' + text + ')');
callbackSuccess(jsonObj);
}
else
{
uiManager.showNotification(1000, "warning", "Failed to get data from server");
}
}
}
xmlhttp.send(null);
}
IDE 缺少基础能力集调用库,这是一个简单的Ajax调用。
最新推荐文章于 2024-11-08 20:37:52 发布