I found the following code at: Send POST data on redirect with JavaScript/jQuery?
$.extend(
{
redirectPost: function (location, args) {
var form = $('<form></form>');
form.attr("method", "post");
form.attr("action", location);
$.each(args, function (key, value) {
var field = $('<input></input>');
//Change the following back to hidden
field.attr("type", "hidden");
//field.attr("type", "text");
field.attr("name", key);
field.attr("value", value);
form.append(field);
});
$(form).appendTo('body').submit();
}
});
I call this redirect from jquery with the following:
var redirect = 'ListDatabaseDetails.cshtml?id=999999';
$.redirectPost(redirect, { 'ServerID': '1', 'DBID': '23' });
Can this be done with a .cshrml target page? If so, how do I retrieve the two values: ServerID and DBID on the target page?
I have tried the following JavaScript on the target .cshtml page with no success-the fields aren't there:
function load_data() {
var ServerID = document.getElementById("ServerID").value;
var DBID = document.getElementById("DBID").value;
}
Thanks for any help.