jquery ajax endpoint
$.ajax({
type:"GET/POST",
url: "target url",
data: "var1=" + data1,
success: function(msg){
$("#targethtml").html(msg)
},
error: function(errormsg){
console.log(errormsg)
}
});
jquery ajax endpoint
$.ajax({
type:"GET/POST",
url: "target url",
data: "var1=" + data1,
success: function(msg){
$("#targethtml").html(msg)
},
error: function(errormsg){
console.log(errormsg)
}
});
jquery ajax
$.ajax({
url : "file.php",
method : "POST",
data: {
//key : value
action : action ,
key_1 : value_key_1,
key_2 : value_key_2
}
})
.fail(function() { return false; })
// Appel OK
.done(function(data) {
console.log(data);
});
js ajax
// For a plain JS solution, use these functions:
function _GET_REQUEST(url, response) {
var xhttp;
if (window.XMLHttpRequest) {
xhttp = new XMLHttpRequest();
} else {
xhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
response(this.responseText);
}
};
xhttp.open("GET", url, true);
xhttp.send();
}
function _POST_REQUEST(url, params, response) {
var xhttp;
if (window.XMLHttpRequest) {
xhttp = new XMLHttpRequest();
} else {
xhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
response(this.responseText);
}
};
xhttp.open("POST", url, true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send(params);
}
// and apply like this:
_GET_REQUEST('http://someurl', (response) => {
// do something with variable response
});
_POST_REQUEST('http://someurl', 'paramx=y', (response) => {
// do something with variable response
});
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us