Skip to content

Instantly share code, notes, and snippets.

@Musilda
Created August 28, 2023 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Musilda/551bcd5892e1346e2b8975bc601d3d42 to your computer and use it in GitHub Desktop.
Save Musilda/551bcd5892e1346e2b8975bc601d3d42 to your computer and use it in GitHub Desktop.
var actionUrl = 'action=tls_send_data&value1=value;
var request = new XMLHttpRequest();
request.open('POST', 'http://www.mysite.com/wp-admin/admin-ajax.php', true);
request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
request.onload = function () {
if (this.status >= 200 && this.status < 400) {
console.log( this.response );
// If successful
var value = JSON.parse( this.response );
} else {
// If fail
//console.log(this.response);
}
};
request.onerror = function() {
// Connection error
};
request.send( actionUrl );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment