Request.JSON
sending a JSON request to the jsFiddle backend. Later on parse and display the data.
by ww9rivers
HTML
<div class='wrapper'>
<p>JSON should show up immediately:</p>
<ul id='p1'></ul>
<ul id='p2'></ul>
</div>
CSS
body {
font-family: Helvetica, Sans, Arial;
}
p, ul {
padding: 10px;
}
ul {
margin: 5px;
border: 2px dashed #999;
}
JavaScript
var json1 = '{"n":"1","txt":"No apostrophe"}';
var json2 = '{"n":"2","txt":"W/ apostrophe (\')"}';
show_json = function(obj) {
$("#p"+obj.n).text(obj.txt);
};
$.post('/echo/json/', {json: json1}, show_json, "json");
$.post('/echo/json/', {json: json2}, show_json, "json");