So, I have a .NET Core 3.1 Pages application and I need to call a PageModel function in a Razor Page from a call to jQuery.Load. It works with no parameters (see below):

$("#divSubComp").load('/Selections/Create?handler=SubCompsPartial', function () {});

// successfully calls …

public PartialViewResult OnGetSubCompsPartial()
// breakpoint hit

However, I need to pass a parameter to OnGetSubCompsPartial and I can't get the syntax right. I currently have the below:

$("#divSubComp").load('/Selections/Create?handler=SubCompsPartial', { id: $(this).id }, function () {});

// and …

public PartialViewResult OnGetSubCompsPartial(string id)

It doesn't reach OnGetSubCompsPartial. I'm getting error:

Failed to load resource: the server responded with a status of 400 () [https://localhost:44323/Selections/Create?handler=SubCompsPartial]

Any thoughts?

Related posts

Recent Viewed