I'm trying to retrieve a value from an editor box when the focus changes using ajax. I want to pull that text and send it as POST data to my handler.
@using (Html.BeginForm()) {
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)<div class="editor-label">
@Html.LabelFor(model => model.PipeSize)</div><div class="editor-field" id="PipeSize">
@Html.EditorFor(model => model.PipeSize)</div>
}<script>$("#PipeSize").focusout(function () {
updateData("ExitHeaderPipeConnSize", ($("#PipeSize").val()))
});
function updateData(field, numvalue) {
$.ajax({
url: "/Eval/UpdateData",
type: 'Post',
data: { fieldName: field, fieldValue: numvalue },
success: function (data) {
//do nothing for now
},
error: function () {
alert("something seems wrong");
}
});
}</script>The UpdateData(string fieldName, string fieldValue) Handler inside the Controller updates the data fieldName properly. But the fieldValue (the text from the editor box) always comes back blank.