My ajax success:function()
runs a line of code which opens a new window and inserts data into it. Rigth now my code looks like this:
success: function(data) {
var url = location.href;
var w = window.open(url);
w.onload = function() {
w.$('#main').html(data);
};
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
It works just fine in Chrome but If I want to run it in Internet Explorer 11 it won't execute w.$('#main').html(data)
. I also tried:
success: function(data) {
var url = location.href;
var w = window.open(url);
w.addEventListener('load', function() {
w.$('#main').html(data);
}, {
once: true
});
}
Which also works fine in Chrome but with IE it gives me the same result as the line above. Does anybody know why this code doesn't work in IE?
$(w).find('#main').html(data);
w.onload = function(){...}
instead of adding an event listener the console says nothing and It doesnt perform anything insidefunction(){...}
. I also tried removing the event listener and the onload and just runw.$('#main').html(data);
inside my success function then the console says "The object does not support the property or method "$"". The line of @Teemu is also not working.