while trying to echo back some html on jsfiddle using jquery deferreds, I'm not getting any data back.
function showData(data1, data2) {
console.log(data1[0]);
console.log(data2);
}
function method1() {
return $.ajax({
type: "post",
url: "/echo/html/",
data: JSON.stringify("test1"),
dataType: 'html'
});
}
function method2() {
return $.ajax({
type: "post",
url: "/echo/html/",
data: {data: "test2"},
dataType: 'html'
});
}
$.when(method1(), method2()).then(showData);
I can't understand what I've done wrong here. Passing the data as an object or as JSON.stringify
, neither seems to work. http://jsfiddle.net/VAy5g/