I have a screen where I should populate with database values using ajax.
When I click the button to fill in the fields the following error appears:
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
I do not know what's going on.
Model Code:
public class Client
{
[Key]
[MaxLength(128)]
public string client_id { get; set; }
[MaxLength(20)]
public string client_cnpj { get; set; }
[MaxLength(255)]
public string client_companyname { get; set; }
[Required]
[MaxLength(255)]
public string client_fantasyname { get; set; }
[Required]
[MaxLength(128)]
public string client_namerepresentative { get; set; }
[Required]
[MaxLength(15)]
public string client_cep { get; set; }
[Required]
[MaxLength(255)]
public string client_street { get; set; }
[Required]
[MaxLength(10)]
public string client_number { get; set; }
[MaxLength(55)]
public string client_complement { get; set; }
[Required]
[MaxLength(128)]
public string client_neighborhood { get; set; }
[Required]
[MaxLength(128)]
public string client_city { get; set; }
[Required]
[MaxLength(2)]
public string client_uf { get; set; }
[MaxLength(128)]
public string client_email { get; set; }
[MaxLength(15)]
public string client_phone1 { get; set; }
[MaxLength(15)]
public string client_phone2 { get; set; }
public int? client_currentcarrier { get; set; }
public int? client_voice { get; set; }
public int? client_web { get; set; }
public int? client_renegotiation { get; set; }
public DateTime? client_datevisitorcontact { get; set; }
[Required]
public string client_note { get; set; }
public int? client_statusnegotiation { get; set; }
[Required]
[MaxLength(128)]
public string client_company_id { get; set; }
[MaxLength(128)]
public string client_supervisingconsultant { get; set; }
[MaxLength(128)]
public string client_supervisingsalessupport { get; set; }
[MaxLength(128)]
public string client_consultant { get; set; }
[MaxLength(128)]
public string client_salessupport { get; set; }
[MaxLength(128)]
public string client_source { get; set; }
public bool client_return { get; set; }
public bool client_sendemail { get; set; }
public DateTime client_dateregister { get; set; }
[ForeignKey("client_company_id")]
public virtual Company Company { get; set; }
public virtual ICollection<HistoricFunnel> HistoricFunnel { get; set; }
public virtual ICollection<ActivityClient> ActivityClient { get; set; }
}
Controller code:
[HttpPost]
public JsonResult ReturnVisit(string id)
{
var visit = _clientAppService.GetById(id);
return Json(new { visit = visit });
}
JavaScript code:
$(".visits-table tr a").click(function () {
var id = $(this).parent().parent().attr("id");
$.ajax({
dataType: "json",
type: "POST",
url: "/Visits/ReturnVisit",
data: { id: id },
success: function (data) {
alert("entrou")
alert(data)
}
});
return false;
});