How to refresh hidden field value using jquery mobile? -
geocoder = new google.maps.geocoder(); geocoder.geocode( { 'address': address}, function(results, status) { if (status == google.maps.geocoderstatus.ok) { var latitude = results[0].geometry.location.lat(); var longitude = results[0].geometry.location.lng(); $('#latitude').val(latitude); $('#longitude').val(longitude); }
latitude , longitude both hidden elements form. both elements have values can see using inspect element. values not display in ajax post form data serialization.
$.ajax({ url: workareas, type: 'post', datatype : 'json', data: $('#workareaformmain').serialize(), async: true, success: function(data) { } });
you must include name id form element included in form serialization:
<input id="latitude" type="hidden" value="1" name="latitude" />
demo
reference: https://api.jquery.com/serialize/
note: "successful controls" serialized string. no submit button value serialized since form not submitted using button. form element's value included in serialized string, element must have name attribute. values checkboxes , radio buttons (inputs of type "radio" or "checkbox") included if checked. data file select elements not serialized.
Comments
Post a Comment