I am new to MVC and tried to try something, but I cannot get this to work.
I have this script, which should insert a partial view inside the page based on the selection of the drop-down list.
$(function () {
$('#ddTipologiaFattura').change(function () {
var selectedID = $(this).val();
$.ajax({
url: '/Admin/Fatturazione/GetPartial/' + selectedID,
contentType: 'application/html; charset=utf-8',
type: 'GET',
dataType: 'html'
})
.success(function (result) {
$('#partialPlaceHolder').html(result);
})
.error(function (xhr, status, error) {
alert(status + '\n' + error)
});
});
});
This is my controller ~ / Areas / Admin / Controllers / FatturazioneController.cs
[RouteArea("Admin")]
[Route("Fatturazione/{action}")]
public class FatturazioneController : Controller
{
private MyEntity db = new MyEntity();
public ActionResult GetPartial(int partialViewId)
{
if (partialViewId == 0)
{
var fatturaAziendaVM = new FatturaPerAziendaViewModel();
ViewBag.Intestatario = new SelectList(db.Azienda, "AziendaNome", "AziendaNome");
return PartialView("~/Areas/Admin/Views/Fatturazione/_ListaAziende.cshtml", fatturaAziendaVM);
}
var fatturaVM = new FatturaViewModel();
return PartialView("~/Areas/Admin/Views/Fatturazione/_Intestatario.cshtml", fatturaVM);
}
I keep getting script error not found . What am I doing wrong?
source
share