I have some problem debugging a script, just because in debug mode all works fine... but not in runtime: I have this function in javascript:
function Add() {
...
$('#Value').val($('#Value').val()); // Value is a div class="input"
...
$.get('@Url.Action("GetSomeData", "_Shared")', { id: parseInt($('#DataID').val()) },
function (result) { $('#SomeData').val(result); });
if ($('#SomeData').val() == "x") {
$('#tmp').val($('#Value').val());
}
else {
$('#tmp').val("0");
}
...
}
and the controller _Shared simply returns an attribute:
public string GetSomeData(int id)
{
return unitOfWork.DataRepository.GetByID(id).Something;
}
What happens is when I use a breakpoint in the "if
", $('#SomeData').val()
has the correct value but if I remove the breakpoint, write a console.log($('#SomeData').val())
and execute, it is alway empty and the $('#tmp').val()
is always "0".
Can anybody tell me what I'm doing wrong?