var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if (xhr.readyState === 4) { callback(JSON.parse(xhr.responseText)); } }; xhr.open('POST', url, true); xhr.setRequestHeader('Content-Type', 'application/json'); xhr.send(JSON.stringify(data));
In jQuery:
$.post(url, data)
In jQuery: