Javascript ajax成功中的Ad调用响应包含document.write

Javascript ajax成功中的Ad调用响应包含document.write,javascript,ajax,document.write,Javascript,Ajax,Document.write,我们目前希望在ajax加载更多后加载广告。但该广告呼叫响应包含document.write,并且在呼叫后将重定向到广告本身。没有方法只获取广告html并附加它。因此,我们必须成功地处理document.write。我看到了iframe的一些东西,但不知道应该如何实现它 $.ajax({ . . . success: function( response ) { var loadedAd = ad call here; -- but it

我们目前希望在ajax加载更多后加载广告。但该广告呼叫响应包含document.write,并且在呼叫后将重定向到广告本身。没有方法只获取广告html并附加它。因此,我们必须成功地处理document.write。我看到了iframe的一些东西,但不知道应该如何实现它

$.ajax({
     .
     . 
     .

    success: function( response ) {
        var loadedAd = ad call here; -- but it redirects to the ad itself due to the document.write in ad response.

谢谢。

从iframe上下文发送ajax请求应该可以做到这一点,或者至少可以解析ad结果代码,用DOM相关函数替换document.write调用

使用iframe上下文评估ajax响应的示例:

var adCode = "document.write('example')",
    iframe = document.getElementById('myFrame');

iframe.contentWindow.eval(adCode);

您应该向我们展示ajax返回的响应。是否应该从iframe发送整个ajax请求?还是只有广告电话?但是我应该如何管理这个iframe呢?你能给我举个小例子吗?