看你ajax怎么写的了试试 $.ajax.setErrorList = function(){alert('this.errorList')}

解决方案 »

  1.   

    this是指当前我自定义的一个对象,不是指$
    比如
    function aaa()
    {
    this.a=0;
    this.str="sdf";
    }
    aaa.prototype={
    getdata:function(){
    $.ajax({
    type: "GET",
    async:false,
    url: g.ConfigError, 
    dataType: "xml", 
    complete: this.setErrorList
    });  },
    setErrorList:function(data){
    this.str=data;
    }
    }主要作用是在获取到数据之后,将相关数据赋于本对象的属性。
      

  2.   

    格式规范一点,上面的看起来太累了。function aaa()
    {
        this.a=0;
        this.str="sdf";
    }
    aaa.prototype={
        getdata:function(){
            $.ajax({
                type: "GET",
                async:false,
                url: g.ConfigError, 
                dataType: "xml", 
                complete: this.setErrorList
            });  
        },
        setErrorList:function(data){
            this.str=data;
        }
    }
      

  3.   

    那也要看你的$.ajax是怎么定义的啊
    可以这样试试
    getdata:function(){
    this.call($.ajax);
            $.ajax({
                type: "GET",
                async:false,
                url: g.ConfigError, 
                dataType: "xml", 
                complete: this.setErrorList
            });
        },
      

  4.   

    我晕,明白你的意思了。$.ajax一个ajax的封装,是jquery库中定义好的。相当于新建了一个xmlhttp请求,从服务器上读取一个文件的数据,并且在完成读取后,触发complete指定的回调函数,即:this.setErrorList。
    而这个函数的定义必须是function fn(data){}
      

  5.   

    刚刚下了个JQ看下
    这样试试
    getdata:function(){
            this.call($.ajax);
            $.ajax(jQuery.extend({
                type: "GET",
                async:false,
                url: g.ConfigError, 
                dataType: "xml", 
                complete: this.setErrorList
            },this));
        },
      

  6.   

    我想就按你这个写法,估计还是不行。
    jquery只是一个工具而已,其内部没有实现传递对象。抛开jquery,我现在是想知道一个思路,或者说是一个设计模式,如何在回调中传递对象。好像在settimeout时,函数传递对象的性质一样。
      

  7.   

    问题已经自行解决了,非常感谢你的提示。最终我是使用Function.call解决的。