IDE 缺少基础能力集调用库,这是一个简单的Ajax调用。
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);
}
相关文档:
今天帮同事解决了js异步调用时出现了中文乱码的问题,具体解决办法如下:
1)首先确认js是否没有对后台传输过来的中文进行解码。
按照网络上写的方法通过js对response的读取出来数据进行多次测试,发现仍然不能解决,细想不一定是此处问题。改换其他办法解决。
2)如果解码解决不了,再看是否是因为网 ......
//用户名校验的方法
//这个方法将使用XMLHTTPRequest对象来进行AJAX的异步数据交互
var xmlhttp;
function verify() {
//0。使用dom的方式获取文本框中的值
//document.getElementById("userName")是dom中获取元素节点的一种方法,一个元素节点对应HTML页面中的一个标签,如果<input& ......
20 个经典的 Ajax + CSS 表格
并不是所有的Web 开发者都会对美化表格数据感兴趣,今天我们收集了20 个功能强大,外观漂亮的基于Ajax + CSS 的表格效果,你可以从这些示例中学习怎么使用这些表格提供的排序和过滤的功能来组织表格中的数据。
现在让我们来看看这些表格:(点击每个样式前面的链接即可进入下载)
#1. ......
function sendAsynchronRequest(url,parameter,callback){
createXMLHttpRequest();
if(parameter == null){
xmlHttp.onreadystatechange = callback;
xmlHttp.open("GET",url,true);//当GET请求时,在地址栏中是带参数的,而参数为NULL,所以用get请求,send(null)
......
function createXMLHttpRequest(){
if(window.ActiveXObject){
http = new ActiveXObject("Microsoft.XMLHTTP");
}else if(window.XMLHttpRequest){
& ......