1
I have a screen where I must popular with database values using ajax.
When I click on the button to fill the fields the following error appears:
Failed to load Resource: the server responded with a status of 500 (Internal Server Error)
I don’t 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;
});
a comma is missing after date: { id: id },
– Eduardo Sampaio
In the code has the comma rs, I deleted a comment that had below, then the comma went together. It goes to the server, only does not return to class.
– Samuel Phellip
tries to do the same example below by removing [Httppost]
– Eduardo Sampaio