$(".button").click(function{
$.get( "example.php", function(data) {
$("div .content").html(data);
$(".button").click(function{
$.get( "example.php", function(data) {
$("div .content .newcontent").html(data);
});
});
});
});
var ajax2 = function(data) {
$("div .content .newcontent").html(data);
}
var button2Click = function(data) {
$.get( "example.php", ajax2);
};
var ajax1 = function(data){
$("div .content").html(data);
$(".button").click(button2Click);
};
var button1Click = function(){
$.get("example.php", ajax1)
};
$(".button").click(button1Click);
$(".button").click(function{
$.get( "example.php" ).done(function(data) {
$("div .content").html(data);
$(".button").click(function{
$.get( "example.php").done(function(data) {
$("div .content .newcontent").html(data);
});
});
});
});
new Promise(function(resolve, reject) {
if (true) {
resolve()
} else {
reject()
}
}
new Promise(function(resolve, reject) {
if (true) {
resolve("It was TRUE!");
} else {
reject("But... HOW!?");
}
}
new Promise(function(resolve, reject) {
$.get("example.php",
function (data) { // Success
resolve(data);
},
function (error){ // Error
reject(error);
}
);
}
var ajaxPromise = new Promise(
function(resolve, reject) {
$.get("example.php",
function (data) { // Success
resolve(data);
},
function (error){ // Error
reject(error);
}
);
}
var ajaxPromise = new Promise(
function(resolve, reject) {
$.get("example.php",
function (data) { // Success
resolve(data);
},
function (error){ // Error
reject(error);
}
);
}
var ajaxPromise = new Promise(/*...*/);
ajaxPromise.then(function(message){
console.log(message);
});
var ajaxPromise = new Promise(/*...*/);
ajaxPromise
.then(function(message){
console.log(message);
})
.then(function(message){
$("div.content").html(message);
})
var ajaxPromise = new Promise(/*...*/);
ajaxPromise
.then(function(message){
console.log(message);
})
.then(function(message){
$("div.content").html(message);
})
.then(function(message){
alert(message);
})
var ajaxPromise = new Promise(/*...*/);
ajaxPromise
.then(function(message){ // resolved
console.log(message);
}, function(errorMessage){ // rejected
alert(errorMessage);
});
var ajaxPromise = new Promise(/*...*/);
ajaxPromise
.then(function(message){ // resolved
console.log(message);
})
.catch(function(errorMessage){ // rejected
alert(errorMessage);
});
var ajaxPromise = new Promise(/*...*/);
ajaxPromise
.then(function(message){
return JSON.parse(message);
})
.then(function(message){
for (m in message) {
// ...
}
})
var ajaxPromise = new Promise(/*...*/);
ajaxPromise
.then(JSON.parse)
.then(function(message){
for (m in message) {
// ...
}
})