JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://jquery-json.googlecode.com/files/jquery.json-2.2.min.js"></script>
JavaScript
var data = {
json: $.toJSON({
text: 'some text',
array: [1, 2, 'three'],
object: {
par1: 'another text',
par2: [3, 2, 'one'],
par3: {}
}
})
}
// 1. ajax()
$.ajax({
url:"/echo/json/",
data:data,
type:"POST",
success:function(response) {
console.log(response);
}
});
// 2. post()
$.post("/echo/json/", data, function(response) {
console.log(response);
});