$.ajax javascript
$.ajax({
url: 'https://example.com/your-page',
success:function(data){
//'data' is the value returned.
},
error:function(){
alert('An error was encountered.');
}
});
$.ajax javascript
$.ajax({
url: 'https://example.com/your-page',
success:function(data){
//'data' is the value returned.
},
error:function(){
alert('An error was encountered.');
}
});
ajax
With Ajax, web applications can send and retrieve data from a server asynchronously without interfering with the display and behaviour of the existing page.
ajax
var xhr = new XMLHttpRequest;
var url = "/";
//POST request
xhr.open('POST', url); //Open the request.
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); //Set the necessary headers for the POST request.
xhr.onreadystatechange = () => {
//Checking if the request has finished and if it was successfull
if (xhr.readyState == 4 && xhr.status == 200) {
console.log(xhr.responseText); //Printing out the response.
//You can also use xhr.responseURL or xhr.responseXML
}
}
xhr.send("lorem=ipsum"); //This sends the request with the specified params. The params should be in format "key=value&key2=value2"
//You can also send a FormData object as the params.
ajax
var xhr = new XMLHttpRequest;
var url = "/?lorem=ipsum";
//GET request
xhr.open('GET', url); //Open the request with the specified url.
xhr.onreadystatechange = () => {
//Checking if the request has finished and if it was successfull
if (xhr.readyState == 4 && xhr.status == 200) {
console.log(xhr.responseText); //Printing out the response.
//You can also use xhr.responseXML
}
}
xhr.send(); //This sends the request to the server with the specified params.
ajax
$.ajax({
method :'GET',
url: baseUrl+'ajaxcontroller/LoadData_To_View',
success:function(data){
$('#item').html(data);
alert(data);
},
complete: function(){
$('#loadingImage2').hide();
},
error:function (xhr, ajaxOptions, thrownError){alert(thrownError);}
});
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