Skip to content

Instantly share code, notes, and snippets.

@kidchenko
Created September 14, 2013 20:03
Show Gist options
  • Save kidchenko/6565155 to your computer and use it in GitHub Desktop.
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
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