Possuo uma tela onde devo popular com valores do banco de dados utilizando ajax.
Quando clico no botão para preencher os campos aparece o seguinte erro:
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
Não sei o que está acontecendo.
Código Model:
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; }
}
Código Controller:
[HttpPost]
public JsonResult ReturnVisit(string id)
{
var visit = _clientAppService.GetById(id);
return Json(new { visit = visit });
}
Código JavaScript:
$(".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;
});