Home Post multiple data items through redirectPost() function to .cshtml page
Reply: 0

Post multiple data items through redirectPost() function to .cshtml page

user1442
1#
user1442 Published in May 25, 2018, 11:09 am

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.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.36891 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO