I have read the jsFiddle user's guide for their JSON echo feature but with no luck of producing a working jsFiddle to echo a JSON message using JQuery.
How can I create a jsFiddle to echo the JSON from their guide:
data: {
json: JSON.encode({
text: 'some text',
array: [1, 2, 'three'],
object: {
par1: 'another text',
par2: [3, 2, 'one'],
par3: {}
}
}),
delay: 3
}
The one example provided is in Mootools which I've never used. So a simple translation from the mootools example into JQuery would be sufficient.
Something like this:
JS Fiddle example.
Basically, point the
url
portion of your$.ajax
function at/echo/jsonp/
and you should be set. JSFiddle's docs say that/echo/json/
works, too, but it looks like that particular URL is down at the moment; using the JSONP service without specifying a callback works just fine, though.Live Demo
Note I have added na additonal resource.. jquery-json
Demo with FireBug Console on View (no need to pull up developer console to see return)
You can also use JSON.stringify