// Post dynamic form using json data function post(uri, data, method) {
// when method not provided use default post method
method = method || "post";
var form = document.createElement("form");
form.setAttribute("method", method);
form.setAttribute("action", uri);
for (var property in data) {
if (params.hasOwnProperty(property)) {
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", property);
hiddenField.setAttribute("value", data[property]);
form.appendChild(hiddenField);
}
}
document.body.appendChild(form);
form.submit();
}
// when method not provided use default post method
method = method || "post";
var form = document.createElement("form");
form.setAttribute("method", method);
form.setAttribute("action", uri);
for (var property in data) {
if (params.hasOwnProperty(property)) {
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", property);
hiddenField.setAttribute("value", data[property]);
form.appendChild(hiddenField);
}
}
document.body.appendChild(form);
form.submit();
}
Comments
Post a Comment