日期:2014-05-17  浏览次数:20897 次

asp 调用ajax 怎么老是不对呀?
js
--------------------------------------------
//function getAdsense(adsenseBox,apartId){
// if(self==top){
// adsenseBox=document.getElementById(adsenseBox);
// rewrite(adsenseBox,"<img src='/Design/_style/loading2.gif' width='136' height='98'/>");
// //Ajax.get("<center>正在加载中……</center>",function(msg){rewrite(adsenseBox,msg);});
// Ajax.get("inc_Counts.asp?strID="+apartId,"v=url",function(msg){rewrite(adsenseBox,msg);});
// }
//}
//function rewrite(rewriteBox,msg){
// if(rewriteBox!=null && msg!=""){
// rewriteBox.innerHTML=msg;
// }
//}



function rewrite(rewriteBox,msg){
if(rewriteBox!=null && msg!=""){
rewriteBox.innerHTML=msg;
}
}
/*
读取广告内容
adsenseBox 显示广告的容器对象
apartId 广告位ID*/
function getAdsense(adsenseBox,apartId,nums,mods){
if(self==top){
adsenseBox=document.getElementById(adsenseBox);
rewrite(adsenseBox,"<img src='/Design/_style/loading2.gif' width='136' height='98'/>loading...");
Ajax.get("inc_Counts.asp?strID="+apartId,"v=url",function(msg){rewrite(adsenseBox,msg);});
}
}

/*
Ajax 数据提交类
Knight.DJ
*/
//自定义函数



//AJAX类
(function(){
var Ajax = window.Ajax = function(opt) {
if(opt.form){
Ajax.fn.postf(opt);
}else{
Ajax.fn.Do(opt);
}
};
Ajax.Setting={
asc: true,
url: "",
dataType: "text",
method: "GET",
data: "",
timeout:10000,
onlySend:false,
charset:"gb2312",
succeed: function(a,b,c){return true},
error: function(a,b,c){return true},
ontimeout:function(a){return true}
};
Ajax.fn = Ajax.prototype = {
Do:function(options){
var settings = Ajax.Setting;
if(options) {
settings = Ajax.fn.Ajax_Extend(settings, options);
}
var isTimeout=false;
var s=settings;
s.method = s.method.toUpperCase();
s.charset = s.charset.toLowerCase();
var a=Ajax.fn.Ajax_GetObj();
var u=s.url;
var b=u.indexOf("?") == -1 ? false:true;
u= b ? u + "&aienrnd=" + Ajax.fn.Ajax_Rnd() : u + "?aienrnd=" + Ajax.fn.Ajax_Rnd();
if(s.method=="GET"){
u=s.data=="" ? u : u + "&" + s.data;
}
var d=null;
if(s.method=="POST"){
d=s.data
}
a.open(s.method,u,s.asc); 
if(s.method=="POST"){
a.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
}
if(!s.onlySend){
window.setTimeout(function(){isTimeout=true;},s.timeout);
a.onreadystatechange =function(){
if(isTimeout){
s.ontimeout();
a.abort();
a=null;
return;
}
if(a.readyState==4){
if(a.status==200){
var t=s.dataType.toLowerCase();
if(t=="text"){
s.succeed(a.responseText,a,s);
}
if(t=="xml"){
s.succeed(a.responseXML,a,s);
}
if(t=="json"){
try{
eval("j=" + a.responseText);
}catch(ex){
j = null;
}
s.succeed(j,a,s);
}
a=null;
}else{
s.error(a.status,a,s);
a=null;
}
}
};
}
a.send(d);
if(!s.onlySend){
if(!(navigator.appName=='Microsoft Internet Explorer')){
if(a.ready