$.ajax({
method: 'post',
url: "http://oamk.fi/~vetapani/persons.json?jsoncallback=?",
success: function(data) {
$("#list").append("test1");
$.each(data, function () {
$("#list").append("<p>");
//loop
$.each(this, function (name, value) {
if(name==="name") {
$("#list").append(value+ " ");
}
if(name==="email") {
$("#list").append(name+': <a href="mailto:'+value+'">'+value+'</a>');
}
});
//
$("#list").append("</p>");
});
console.log('LOG success '+data);
$("#list").append("test2");
},
error: function(data) {//ошибки запроса
console.log('LOG error '+data);
var arr=['Your browser does not support Ajax',
'Request failed',
'Address does not exist',
'The waiting time left'];
alert(arr[data]);
}
}).done( function(data) { console.log('LOG done '+data) });
$.ajax({
type: 'post',
url: "http://oamk.fi/~vetapani/persons.json?jsoncallback=?",
dataType: 'json',
data: {
format: 'json'
},
success: function(data) {
$("#list").append("test1");
$.each(data, function () {
$("#list").append("<p>");
//loop
$.each(this, function (name, value) {
if(name==="name") {
$("#list").append(value+ " ");
}
if(name==="email") {
$("#list").append(name+': <a href="mailto:'+value+'">'+value+'</a>');
}
});
//
$("#list").append("</p>");
});
console.log(data);
},
error: function(num) {//ошибки запроса
console.log(num);
var arr=['Your browser does not support Ajax',
'Request failed',
'Address does not exist',
'The waiting time left'];
alert(arr[num]);
}
});