2010-03-29 109 views
1

我遇到IE导致两个错误的问题:
1.对象不支持此属性或方法
2.调用被调用者拒绝。在windows上导致回调函数导致错误,例如:

意向: 要调用window.opener.myObject方法会使用AJAX来获取一些数据,并通过在回调函数 住在发起呼叫将要处理的响应弹出窗口嵌套函数数据并相应地修改弹出窗口html。

这里是一个场景: 我拉起弹出窗口,处理一些特定的操作。 该弹出窗口调用使用ajax调用的window.opener.myObject方法。 我正在通过弹出窗口函数来处理响应,它与ff和safari协同工作,但不能与ie协同工作。 这里是代码示例

//RELEVANT SCRIPT ON POPUP WINDOW 
$('#myButton').live('click', function() { 
    var h = window.opener.myObject, p = { 'p1': 1 }; 
    var responseHandler = function(responseObj) { 
     //in IE we never got here 
     if (!responseObj) { 
      alert('Unexpected error!! No response from server'); 
      return false; 
     } 
     //..handle response 

    }; 
     p.p1 = $('#control').val(); 
     h.executeMethod(p, responseHandler); 
}); 

//RELEVANT SCRIPT ON WINDOW OPENER MYOBJECT 
try { 
$.ajax({ 
    type: 'POST', 
    async: true, 
    url: url, 
    data: postData, 
    dataType: "json", 
    contentType: 'application/x-www-form-urlencoded; charset=utf-8', 
    success: r, // r here is reference to my responseHandler popup window function 
    error: handleError 
}); 
} catch (ex) { 
alert(ex.message); 
} 

任何提示?

回答

1

我已经使其工作,不知道如果这是正确的方式或不,但现在它的工作。 我修改开窗器myObject的代码:// 相关的脚本ON开窗器MYOBJECT

try { 
$.ajax({ 
    type: 'POST', 
    async: true, 
    url: url, 
    data: postData, 
    dataType: "json", 
    contentType: 'application/x-www-form-urlencoded; charset=utf-8', 
    success: r, // r here is reference to my responseHandler popup window function** 
    error: handleError 
}); 
} catch (ex) { 
alert(ex.message); 
} 

到:

//RELEVANT SCRIPT ON WINDOW OPENER MYOBJECT 
try { 
$.ajax({ 
    type: 'POST', 
    async: true, 
    url: url, 
    data: postData, 
    dataType: "json", 
    contentType: 'application/x-www-form-urlencoded; charset=utf-8', 
    success: function(myResponseObj) { 
     r.call(null, myResponseObj); 
    } 
    error: handleError 
}); 
} catch (ex) { 
alert(ex.message); 
} 

如此成功的jQuery AJAX的处理程序修改为:

success: function(myResponseObj) { 
    r.call(null, myResponseObj); 
} 

它现在可以工作:-) ...