I want to get model's specific value in ajax success. I can not use Json result in here because I also need to load the model value in div container with partial view.
Here is my model
public class ProductModel
{
public int ProductId { get; set; }
public decimal? Cost { get; set; }
public string Description { get; set; }
public bool IsCostUpdated { get; set; }
}
I want to get the value of IsCostUpdated in ajax success only. In controller I have to returned strongly typed partial view. Here is the code
[HttpPost]
public ActionResult CheckProductCost(ProductModel model)
{
ModelState.Clear();
using (var db = DataContext.Db)
{
model.IsCostUpdated = model.CheckUpdate(db);
}
return PartialView("ProductDataTable", model);
}
this is my ajax call code
$.ajax({
url: productCostUrl,
dataType: 'html',
type: 'POST',
data: $('body').find('.productTable').closest('.dataComponent').find(':input').serialize(),
success: function (d) {
var isSuccess = d.IsCostUpdated; [I want this value]
$('body').find('.productTable').html(d)
}
});