解决方案 »
- 这个正则怎么写啊?
- setCookie()的问题~~~~~~~~~~~~~~~~~~~~~~~
- 关于mysql默认值的问题
- 用户未登录网站之前不能使用一些连接??
- 框架问题!!!
- 数组问题~~~~
- 关于PHPLIB配置问题。连接数据库出现Access denied for user: 'UserWeb@localhost'
- 谁有无刷新的PHP聊天室的源代码。高手求得!
- 请问我的WdatePicker.js怎么在服务器上失效了?在本地测试都可以的。都已经用了2年都没问题的啊。。。
- 数据库中的数据遍历出来之后,怎么才能将它存入另一数据表,求大神,php新手,老是不会,很难过过
- 数组归类问题
- 往类中添加数组如何实现?
alert(s.response)
你用下状态判断,你ff看下它执行了几次
应该绑定个回调事件。<script type='text/javascript'> var ajax=function (){};
ajax.prototype.xmlhttp=null;
ajax.prototype.url='';
//ajax.prototype.response=null;
ajax.prototype.seturl=function(url)
{
this.url=url;
}
ajax.prototype.setaction=function(action)
{
this.action=action;
}
ajax.prototype.setstr=function(str)
{
this.str=str;
}
ajax.prototype.callBack = {
success : function(o){}
,fail : function(o){}
}
ajax.prototype.ajaxrequest=function()
{
if(window.ActiveXObject)
{
this.xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
}
else if(window.XMLHttpRequest)
{
this.xmlhttp=new XMLHttpRequest();
}
if(this.xmlhttp!=null)
{
var tmp = this.xmlhttp;
var self = this;
this.xmlhttp.onreadystatechange=function ()
{
if(tmp.readyState==4)
{
if(tmp.status==200)
{
// ajax.prototype.response=tmp.responseText;
self.callBack.success.apply(tmp,[tmp.responseText])
}
else
{
self.callBack.success.apply(tmp,[tmp.statusText])
}
}
}
if(this.action=='get')
{
this.xmlhttp.open('GET',this.url,true);
this.xmlhttp.send(null);
}
else if(this.action=='post')
{
this.xmlhttp.open('POST',this.url,true);
this.xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
this.xmlhttp.send(this.str);
}
}
else
{
alert('Your browser does not support AJAX');
}
}
function click1()
{
alert(1);
var s= new ajax;
s.seturl('s1.php?'+Math.random());
// s.setaction('alert');
s.setstr(null);
s.setaction('get');
s.ajaxrequest();
s.callBack = {
success : function(text){
alert(text);
}
,fail : function(text){
alert("Error:"+text);
}
}
s=null;
}
</script>
ajax.prototype.xmlhttp=null;
ajax.prototype.url='';
//ajax.prototype.response=null;
ajax.prototype.seturl=function(url)
{
this.url=url;
}
ajax.prototype.setaction=function(action)
{
this.action=action;
}
ajax.prototype.setstr=function(str)
{
this.str=str;
}
ajax.prototype.callBack = {
success : function(o){}
,fail : function(o){}
}
ajax.prototype.ajaxrequest=function()
{
if(window.ActiveXObject)
{
this.xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
}
else if(window.XMLHttpRequest)
{
this.xmlhttp=new XMLHttpRequest();
}
if(this.xmlhttp!=null)
{
var tmp = this.xmlhttp;
var self = this;
this.xmlhttp.onreadystatechange=function ()
{
if(tmp.readyState==4)
{
if(tmp.status==200)
{
// ajax.prototype.response=tmp.responseText;
self.callBack.success.apply(tmp,[tmp.responseText])
}
else
{
self.callBack.fail.apply(tmp,[tmp.statusText])
}
}
}
if(this.action=='get')
{
this.xmlhttp.open('GET',this.url,true);
this.xmlhttp.send(null);
}
else if(this.action=='post')
{
this.xmlhttp.open('POST',this.url,true);
this.xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
this.xmlhttp.send(this.str);
}
}
else
{
alert('Your browser does not support AJAX');
}
}
function click1()
{
var s= new ajax;
s.seturl('s1.php?'+Math.random());
// s.setaction('alert');
s.setstr(null);
s.setaction('get');
s.ajaxrequest();
s.callBack = {
success : function(text){
alert(text);
}
,fail : function(text){
alert("Error:"+text);
}
}
s=null;
}
</script>