I am trying to convert an ajax request to vanilla JavaScript
$.ajax({
url: 'http://foo.bar/hi',
type: 'post',
data: {args: params},
success: function(data){
},
});
I have tried the following
var xhr = new XMLHttpRequest();
var data = {args: params};
xhr.open("POST", 'http://foo.bar/hi', true);
xhr.send(data);
I am connecting to an external device with a web based interface and not getting any response on the device. It is as if I never sent a request
Theoretically, the original ajax request will perform the action, however, there is a problem with the jQuery portion of my program so I am trying to convert it to vanilla javascript and bypass the jQuery
onreadystatechangeso how are you getting any sort of response?XMLHttpRequest. You don’t have anything in your jQuerysuccesshandler, and you don’t have the equivalent of thesuccesscallback in your XHR approach.curl? - since you have no response handlers defined, either in your jquery or your vanilla version, you can't even accurately say that you aren't getting a response.