Converting xhr to $.ajax call