I am trying to access the status code of the request fired when I set the src attribute of the iFrame.
Here is my code:-
$('.player-modal-button').on('click', function (e) {
var dataSource = $(this).data('src');
var playerModal = $('#player-modal');
playerModal.modal();
});
Because I am setting the src later on button click, there is another request fired to load the video.
Google Chrome Network Tab Output
Request URL: http://mywebsite.com/videos/play/4328
Request Method: GET
Status Code: 302 Found
Note:- This request is fired automatically by the browser when the iFrame src is set.
This request returns a 302 status code if the user has logged out automatically for some reason. And then login page gets loaded in the iFrame.
What I want to do is display an alert the first time it returns a 302 status code. But I do not know how to track the request in javascript.
Can someone please guide me how to get the status code from the browser?