2017-10-19 40 views
0

我有一個網頁存在於我的web服務器上(我無法修改),它發送一個jax請求。在那個頁面中是一個iFrame,其中包含一個我可以改變的頁面,它存在於同一個域中。從該iFrame中,我試圖使用ajaxSend來捕獲父頁面正在發送的內容,但它似乎沒有工作。這可能是從iframe做到的嗎?使用ajaxSend從iframe中的父頁面捕獲請求

<script src="Scripts/jquery-1.4.1.min.js"></script> 
<script type="text/javascript"> 
    $(document).ready(function() { 
     $(document).ajaxSend(function (evt, xhr, settings) { 
      if (xhr != null) { 
       $("#request").text(xhr); 
      } 
     }); 
    } 
</script> 

回答

0

由於jakecigar了jQuery現場爲回答這個問題。

它必須在完全相同的域中。你將不得不從iframe來導航到父

$(parent.document).ajaxSend(... 應該工作。

JΛ̊KE