wenn ich auf Google-Karte, erhalte ich lat & lng wie unten senden . danach, ich sende Form über Ajax unter Verwendung von AJAX:Ajax nicht Textbox Wert von google map lat & lng an der Steuerung in mvc
<script>
$("#btnAdd").click(function (e) {
e.preventDefault();
var dataa = new window.FormData($("#jobDetails")[0]);
$.ajax({
url: "/Job/Create",
data: dataa,
type: "Post",
contentType: false,
processData: false,
dataType: "Json",
success: function (result) {
$("#result").html(result.id);
},
error: function() {
alert("خطا!");
}
});
});
</script>
aber in ActionResult
erhalten i lat & lng 0 wie unten
dieser Code meiner Sicht ist:
<div class="form-group">
@Html.LabelFor(model => model.Job.PickUpAddress.Lat, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Job.PickUpAddress.Lat, new { htmlAttributes = new { @class = "form-control", id = "pickLat", @value = "" } })
@Html.ValidationMessageFor(model => model.Job.PickUpAddress.Lat, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Job.PickUpAddress.Lng, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Job.PickUpAddress.Lng, new { htmlAttributes = new { @class = "form-control", id = "pickLng", @value = "" } })
@Html.ValidationMessageFor(model => model.Job.PickUpAddress.Lng, "", new { @class = "text-danger" })
</div>
</div>
und dies ist mein Modell:
public double Lat { get; set; }
public double Lng { get; set; }
Ich weiß nicht, warum Ajax senden Lat & Lng 0. kann jemand mir helfen?
Zeigen Sie Ihren Ansichtscode, keine Bilder davon! Und was ist Ihre Controller-Methode und Modell - Ihre Formularsteuerelemente haben 'name =" Job.PickupAddress.Lat "', nicht 'name =" Lat "' –
Und was ist das Element mit 'id =" jobDetails "'? –
@StephenMuecke Ich ordne Textbox mit 'javascript' und pro' id' nicht 'name'.es ist lustig, weil wenn ich Textbox Wert wie diese' document.getElementById ('pickLat'). Value = "100" ', 'controller 'receive' Lat = 100' aber wenn ich auf google map klicke, wird kein Wert gesendet. – Mojtaba