Skip to content

Instantly share code, notes, and snippets.

@alexandreaquiles
Last active August 29, 2015 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexandreaquiles/8699096 to your computer and use it in GitHub Desktop.
Save alexandreaquiles/8699096 to your computer and use it in GitHub Desktop.
Ajax na mão vs. Ajax com JQuery.
function finaliza(id){
$.post("finalizaTarefa", {"id": id}, function(){
$("#tarefa_"+id).html("Finalizado");
});
}
function finaliza(id){
var xmlhttp;
if(window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else { //IE 5 e 6
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
document.getElementById("tarefa_"+id).innerHTML = "Finalizado";
}
}
xmlhttp.open("POST", "finalizaTarefa", true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-urlencoded");
xmlhttp.send("id="+id);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment