Created
September 14, 2013 20:03
-
-
Save kidchenko/6565155 to your computer and use it in GitHub Desktop.
Maneira simples e elegante de montar mensagens de respostas para callback usando $.append
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
success: function(response) { | |
$('.tour').html('<p></p>') //cria um elmento p em .tour | |
.find('p') //busca o elemento p recem criado | |
.append('Trip to ' + response.description) //monta a mensagem | |
.append(' at $' + response.price) | |
.append(' for ' + response.nights + ' nights') | |
.append('. Confirmation: ' + response.confirmation); | |
} | |
//OU | |
var msg = $("<p></p>"); //cria um elmento p | |
msg.append("Destination: " + result.location + ". "); //monta a mensagem | |
msg.append("Price: " + result.totalPrice + ". "); | |
msg.append("Nights: " + result.nights + ". "); | |
msg.append("Confirmation: " + result.confirmation+ "."); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment