Is there a way in jQuery to create and submit a form on the fly.
Something like below.
Title Text Goe
Its My version without jQuery, simple function can be used on fly
Function:
function post_to_url(path, params, method) {
method = method || "post";
var form = document.createElement("form");
form.setAttribute("method", method);
form.setAttribute("action", path);
for(var key in params) {
if(params.hasOwnProperty(key)) {
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", key);
hiddenField.setAttribute("value", params[key]);
form.appendChild(hiddenField);
}
}
document.body.appendChild(form);
form.submit();
}
Usage:
post_to_url('fullurlpath', {
field1:'value1',
field2:'value2'
}, 'post');