I wrote this jQuery code:
<script type="text/javascript">
$.ajax({
url: "http://www.mysite.com/login.aspx",
context: document.body,
success: function(html) {
$('body').append(html);
}
});
</script>
It works in IE in that it’s successfully redirected but nothing happens in Firefox and Safari.
Why?
Try
$('body').html(html)instead. You should use append with already parsed html (ie. wrapped as jQuery object).But generally, if you want to do only readirect, and you don’t care what url is in location bar – use normal redirect (
document.location = 'url').If you want to replace page content with ajax, it’s usually better not to replace whole
bodybut only somecontainerdiv inside.