有一个表单,其中的一个项目是提交视图AJAX帖子, 但是当我发布时,表单在第一次提交几次白色时它只提交来自ENUM下拉列表的AJAX项目+值, 其余项目值为NUll,因此模型无效&之后,我得到了除ajax项目之外的所有项目... 我在页面中的脚本列表: 我希望提交(发布)到我的控制器的是值:lat
<script src="/Scripts/modernizr-2.8.3.js"></script>
<script src="/Scripts/jquery-3.1.0.js"></script>
<script src="/Scripts/jquery-ui-1.12.0.js"></script>
<script src="/Scripts/underscore-min.js"></script>
<script src="/Scripts/moment.js"></script>
<script src="/Scripts/bootstrap.js"></script>
<script src="/Scripts/respond.js"></script>
<script src="/Scripts/GenresScripts.js"></script>
<script src="/Scripts/bootbox.min.js"></script>
<script src="/Scripts/jquery.validate.js"></script>
<script src="/Scripts/jquery.validate.unobtrusive.js"></script>
<script type="text/javascript">
var map;
var initialCenter;
var initialZoom;
var elevationService;
var geocoder;
function init() {
var mapOptions = {
center: new window.google.maps.LatLng(52.373922, -3.427734),
zoom: 14,
mapTypeId: window.google.maps.MapTypeId.TERRAIN,
mapTypeControl: false
};
map = new window.google.maps.Map(document.getElementById('mapDiv'), mapOptions);
initialCenter = mapOptions.center;
initialZoom = mapOptions.zoom;
addGeocodingService();
addShowCoords();
}
google.maps.event.addDomListener(window, "load", init);
function addGeocodingService() {
geocoder = new window.google.maps.Geocoder();
}
function geocodeAddress() {
var address = document.getElementById("address").value;
geocoder.geocode({ 'address': address },
function(results, status) {
if (status === window.google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
addShowCoords(results[0].geometry.location);
//var position = results[0].geometry.location;
} else {
alert("Geocode failed with the following error: " + status);
}
});
};
function addShowCoords() {
window.google.maps.event.addListener(map,
'center_changed',
function() {
var newCenter = map.getCenter().toString();
var lat = newCenter.toString();
document.getElementById('LatLong').innerText = lat;
});
$.ajax({
type: "POST",
//ActionName
url: "Create",
//Just for test hard code value
//Should be : data: { LatLong:lat},
data: { LatLong: lat },
async: false,
datetype: "html",
success: function (data) {
$('#result').html(data);
return false;
},
error: function () {
alert("oops, something bad happened");
}
});
};
</script>