@jerad
To listen to an HTTP response from an iframe, you can use the postMessage API for cross-origin communication. Here's how you can do it:
1 2 3 4 5 6 7 |
window.addEventListener('message', function(event) { // Check if the message is coming from the iframe if (event.source === iframe.contentWindow) { // Handle the response from the iframe console.log(event.data); } }); |
In the iframe document, include the following code to send the message to the parent window:
1 2 |
var responseData = 'HTTP response data'; parent.postMessage(responseData, '*'); |
Replace 'HTTP response data' with the actual data you want to send to the parent window.
By following these steps, you can listen to an HTTP response from an iframe using the postMessage API for communication between different windows or iframes.