First problem
I work with code for another coder.
I must check correctly cron expression and I can change many line code in program. I take argument from form and trying send this data to controller MVC
var outl = document.getElementById('Frequency').value;
var tmp = checkValid(outl);
and
function checkValid(checkExpression)
{
var tmp = JSON.stringify(checkExpression);
$.ajax({
contentType: 'application/json; charset=utf-8',
dataType: String,
type: 'POST',
url: '/Service/isValid',
data: tmp,
success: function (isvalid)
{
return isvalid;
}
});
console.log(tmp);
}
Controller in MVC looks like:
public JsonResult isValid(string dataFromJson)
{
Options options = new Options()
{
ThrowExceptionOnParseError = true,
Use24HourTimeFormat = true,
};
try
{
ExpressionDescriptor ceh = new ExpressionDescriptor(dataFromJson, options);
string description = ceh.GetDescription(DescriptionTypeEnum.FULL);
return Json(true);
}
catch (FormatException)
{
return Json(false);
}
}
The parameters dataFromJson are llways null. Why? Really, I don't see where I went wrong.
Second part
In controller I return JSON - its good idea? How to get response from this controller in Ajax