javascript - Not able to get serialized Array of Kendo UI Form -
i have simple form, have form element 1 input type , button.
when click button, trying form data using
var fdata = $("#test").serializearray();
however reason, not able values of form.
what reason this?
there several issues. firstly, input
has no name
attribute, cannot serialized. secondly, create variable called fdata
, log fdata
- js case sensitive. form being submit in usual method when button clicked means processing prevented after first alert
. prevent can change button standard type, instead of submit button:
<form id="test" method="post"> <p> <input id="val" name="foo" /> </p> <button class="k-button" id="rset" type="button">submit</button> </form>
or alternatively can set code run under submit
event of form, , use preventdefault
stop standard form submission:
$("#test").submit(function (e) { e.preventdefault(); alert('ok'); var fdata = $(this).serializearray(); alert('rdata ' + fdata); });
Comments
Post a Comment