JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>.ajax()</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="content-language" content="en" />
</head>
<body>
<h2>Testing .ajax() in IE7</h2>
<ul class="logger"></ul>
<div class="result"></div>
</body>
</html>
CSS
.logger {
list-style: none; border: 1px solid #9F9FFF; padding: 5px 0 5px 5px; background-color: #EFEFFF; float: left; margin-top: 20px; width: 350px;
}
.result {
border: 1px solid #DDDDDD; padding: 5px; background: none; float: left; margin-top: 20px; width: 450px; overflow: hidden;
}
.result.success {
border-color: #008000;
}
.result.error {
border-color: #FF0000;
}
JavaScript
$(document).ready(function() {
var $logger = $('ul.logger'),
$result = $('div.result'),
url = '//' + window.location.host + '/echo/html/';
if (window.console && $.isFunction(console.log)) {
console.log(' url -> ' + url + '\n protocol -> ' + window.location.protocol);
}
$.ajax({
type: 'POST',
dataType: 'html',
url: url,
async: true,
cache: false,
data: {
html: '<p>This test fails in IE7 with jQuery 1.4.x if you use an url without protocol like this: ' + url + '</p>',
delay: 1
},
beforeSend: function() {
$logger.append($('<li>').text(new Date().toLocaleString() + ': beforeSend()'));
},
success: function(data) {
$logger.append($('<li>').text(new Date().toLocaleString() + ': success()'));
$result.addClass('success');
if (data) {
$result.html(data);
}
},
complete: function() {
$logger.append($('<li>').text(new Date().toLocaleString() + ': complete()'));
},
error: function() {
$logger.append($('<li>').text(new Date().toLocaleString() + ': error()'));
$result.addClass('error');
}
});
});