Reputation: 1433
Can anyone please tell me what is wrong with the given below code. I am trying to load data in a div using json call.
function getData() {
$.ajax({
url: "http://echo.jsontest.com/key/value/one/two",
type: "get",
dataType: "JSON"
}, function(data){
$('#99').append(JSON.stringify(data));
});
return false;
}
It would be great if someone can put some light on $.ajax, $.get, $.post and $.getJSON
Upvotes: 1
Views: 22998
Reputation: 7408
You're mixing $.get
and $.ajax
Use this instead:
$.ajax({
url: "http://echo.jsontest.com/key/value/one/two",
dataType: "json"
}).success(function(data){
$('#data').append(JSON.stringify(data));
});
Demo: http://jsfiddle.net/j3vsg/
Upvotes: 6