DEV Community

Discussion on: Why is there such profound and intense hatred towards jQuery in the WebDev world?

Collapse
 
prahladyeri profile image
Prahlad Yeri • Edited

While fetch is wonderful, it isn't a drop in replacement for jQuery's $.get and $.post! It has very different behavior - it doesn't save cookies in a get/post request for example, so it won't work in cases where authentication is required.

fetch also lacks compatibility with older browser versions (such as IE9 and earlier). The compatible way of doing AJAX in pure JS is this (which is relatively less elegant):

var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function()
{
    if(xmlHttp.readyState == 4 && xmlHttp.status == 200)
    {
        alert(xmlHttp.responseText);
    }
}
xmlHttp.open("post", "server.php"); 
xmlHttp.send(formData);