> I have a regular javascript object (with key/values) and would like to
> submit it to server by POST with complete page reload through jQuery. Just
> as with regular HTML forms. I searched for a few hours for some solution and
> have not found any. There are many examples for jQuery AJAX forms but I do
> not want AJAX.
> For instance there is $.post method, which accepts JS object as second
> parameter, however this is also AJAX method. I look for some soultion to
> send variables and completely re-request the page.
> Can anybody point me how that should be done?

For that you would want to dynamically create a form and then submit
it.  For example:

var s = '<form action="myURL" method="POST">';

// add inputs corresponding to your javascript object
for (p in myObject) {
    s += '<input type="text" name="'
        + encodeURIComponent(p) + '" value="'
        + encodeURIComponent(myObject[p])
        + '" />';
}
s += '</form'>;

// add the form to the document
var $form = $(s).appendTo('body');

// submit it
$form.submit();


Reply via email to