I tried to reload a partial view using ajax and jquery like this
$.ajax({
type: "Get",
async: false,
url: "http://localhost:31569/api/Event/Get/" + eventId,
success: function (data) {
console.log(data);
var ladate = data.eventDate.split('T')[0];
var an = ladate.split('-')[0];
var month_converted = Global.ConvertToMonth(ladate.split('-')[1]);
var day = ladate.split('-')[2];
var finaldate = day + " " + month_converted + " " + an;
$("#detailId").val(data.id);
$("#detailEventTitle").val(data.eventTitle);
$("#detailLieu").val(data.lieu);
$("#DetailEventDate").val(finaldate);
$("#detailDescription").val(data.description);
$("#detailNbParticipant").val(data.nbParticipant);
$("#detailNbParticipantActuel").val(data.nbParticipantActuel);
$("#detailLogo").val(data.logo);
$("#divLogo").empty();
$("#divLogo").append(' <img id="imgLogo" src="@Html.Action("Image","Event", new { byteArray = Model.Logo })" />');
},
error: function (xhr, status, error) {
window.location = "/";
}
});
The problem is in this line
$("#divLogo").append(' <img id="imgLogo" src="@Html.Action("Image","Event", new { byteArray = Model.Logo })" />');
the action is not called and I get as result
Html
<img id="imgLogo" src="@Html.Action(" image","event",="" new="" {="" bytearray="Model.Logo" })"="">
Javascript Error
@Html.Action(:1 GET http://localhost:31569/@Html.Action( 404 (Not Found)
So I need to know
- What is the reason of this problem?
- How can I fix it?