JSFiddle - React, Tailwind, and code Playground
by Wudiemperor
HTML
<div class='wrapper'>
<p>JSON will be received in 3 seconds</p>
<ul id='post'></ul>
</div>
CSS
body {
font-family: Helvetica, Sans, Arial;
}
p, ul {
padding: 10px;
}
ul {
margin: 5px;
border: 2px dashed #999;
}
JavaScript
$.ajax({
type: 'post',
dataType: 'json',
url: '/echo/json/',
data: {
json: JSON.stringify({
text: 'some text',
array: [1, 2, 'three'],
object: {
par1: 'another text',
par2: [3, 2, 'one'],
par3: {}
}
})
},
done: function(response) {
alert(response);
show_response(response, $('#post'));
}
});
show_response = function(obj, result) {
console.log(obj);
obj.each(function(v, k) {
$('li', {
text: k + ': ' + v
}).appendTo(result);
});
};