Created
August 28, 2023 14:27
-
-
Save Musilda/551bcd5892e1346e2b8975bc601d3d42 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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