Hacker News new | ask | show | jobs
by gokulk 5046 days ago
$.ajax({ type: 'POST', url: "path/to/api", data: "banana=yellow", success: function (data) { alert("Success: " + data); }, });

can be written as

jQuery.post('path/to/api',{banana:yellow},function(data){alert("Success: "+data);});

much simpler and easy than

var r = new XMLHttpRequest(); r.open("POST", "path/to/api", true); r.onreadystatechange = function () { if (r.readyState != 4 || r.status != 200) return; alert("Success: " + r.responseText); }; r.send("banana=yellow");

nevermind got the joke. but i think jQuery helps write faster code sometimes