I have no way to fix the javascript. The page uses a XHR
function openPOST(url, params, callback) {
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", url, true);
xmlhttp.setRequestHeader('Content-Type', "application/x-www-form-rlencoded");
xmlhttp.send(params);
xmlhttp.onreadystatechange = function() {
if (this.readyState === 4) {
if (xmlhttp.status === 200) {
if (callback) callback(this.responseText);
}
}
}
return xmlhttp;
};
At the time of page load, use the following query
document.addEventListener('DOMContentLoaded', function () {
...
function go() {
openPOST("/home/someaction", "query=123", function (count) {
document.querySelector("h1").textContent = count;
});
}
...
go();
...
});
Is it possible to implement such a code to ASP.NET MVC so he moved on to another page, but did not put the result in another page ?
I need to POST requests are redirected to the page to a different address.
the following code inserts the result in document.querySelector("h1").textContent
public void someaction() {
Response.Status = "307 Temporary Redirect";
Response.AddHeader("Location", "http://example.com");
}
EDIT: User opened an old version of our webpage in his browser. This webpage makes an ajax call to our webserver and inserts response as a string (no eval(), js code won't work). Is there are any way to reload this web page from our server?