Jquery Serialize A Div Content To Post Input Data
I'm trying to use the jQuery.serialize() function, generally used on form, to serialize data inside a div. I can't use the form tag as I'm working in asp.net webforms that wraps ev
Solution 1:
Try
$('#sidebar-form :input, #sidebar-form textarea, #sidebar-form select').serialize();
Or
$("#sidebar-form").find("select, textarea, input").serialize()
Solution 2:
you will have to build your own function for that
functionformSerializer(selector){
data="";
// look for every form field
selector.find('input, select, textarea').each(function(){
// serialize data
data+=$(this).attr("name")+"="$(this).val()+"&";
});
// remove the last & charreturn data.replace(/&$/g,"");
}
function call
$.ajax({
type: "POST",
url: '/API/InfoRequest.ashx',
data: formSerializer(form),
dataType: "text",
success: function (response) {
}
})
Post a Comment for "Jquery Serialize A Div Content To Post Input Data"