send ajax code example
Example 1: ajax request
$.ajax({
url : 'more_com.php',
type : 'GET',
data : {variable1 : "some data"},
success : function(result){
},
error : function(result, statut, error){
}
});
Example 2: javascript send post request
let data = {element: "barium"};
fetch("/post/data/here", {
method: "POST",
body: JSON.stringify(data)
}).then(res => {
console.log("Request complete! response:", res);
});
window.post = function(url, data) {
return fetch(url, {method: "POST", body: JSON.stringify(data)});
}
post("post/data/here", {element: "osmium"});
Example 3: ajax open a request
<script>
function loadDoc() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("demo").innerHTML = this.responseText;
}
};
xhttp.open("GET", "TheFileYouWant.html", true);
xhttp.send();
}