如何使用jquery mobile刷新隐藏字段值?

如何使用jquery mobile刷新隐藏字段值?,jquery,jquery-mobile,Jquery,Jquery Mobile,纬度和经度都是隐藏在表单中的元素。这两个元素都有我可以使用inspect元素看到的值。但值不会显示在ajax post表单数据序列化中 geocoder = new google.maps.Geocoder(); geocoder.geocode( { 'address': address}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) {

纬度和经度都是隐藏在表单中的元素。这两个元素都有我可以使用inspect元素看到的值。但值不会显示在ajax post表单数据序列化中

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);
        }

必须为要包含在表单序列化中的表单元素提供名称和id:

$.ajax({
                        url: workAreas,
                        type: 'POST',
                        dataType : 'json',
                        data:  $('#workAreaFormMain').serialize(),
                        async: true,
                        success: function(data)
                        {  

                        }                    
                    });

参考:

注意:只有“成功的控件”被序列化为字符串。由于未使用按钮提交表单,因此未序列化任何提交按钮值。要将表单元素的值包含在序列化字符串中,该元素必须具有name属性。复选框和单选按钮(输入类型为“单选”或“复选框”)中的值仅在选中时才包括在内。文件选择元素中的数据未序列化

<input id="latitude" type="hidden" value="1" name="latitude" />