I want to make an ajax request to allow the user to send some data from input field to database and then return it to the input field, as same as the comment box, so the data should inserted into the database and then displayed in the input field without reloading the page, here is my code:
function getHTTPObject(){
if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
else if (window.XMLHttpRequest) return new XMLHttpRequest();
else {
alert("Your browser does not support AJAX.");
return null;
}
}
// Implement business logic
function doWork(){
httpObject = getHTTPObject();
if (httpObject !== null) {
httpObject.open("GET", "a page or a controller action"
, true);
httpObject.send(null);
// httpObject.onreadystatechange = setOutput;
}
}
so, how I can make a request that can call a controller action without leaving the entire page?