1 JavaScript implementation dynamically creates a form to send data
2 data transfer Get or post
1Global.namespace ("Dysend");2 3 /**4 * Post mode submission data for normal submission mode dynamically create form form for submission5 * 6 * @param {}7 * path action URL paths8 * @param {}9 * Params an objectTen * @param {} One * Methodtype A */ -GLOBAL. Dysend.senddyform =function(path, params, methodtype) { -Methodtype = Methodtype | | "POST"; the varform = document.createelement ("form"); -Form.setattribute ("Method", methodtype); -Form.setattribute ("Action", path); - for(varKeyinchparams) { + varHiddenField = document.createelement ("Input"); -Hiddenfield.setattribute ("type", "hidden"); +Hiddenfield.setattribute ("name", key); AHiddenfield.setattribute ("Value", Params[key]); at Form.appendchild (HiddenField); - } - document.body.appendChild (form); - form.submit (); -}
JavaScript enables dynamic creation of form send data