Luke Rayner Luke Rayner - 3 months ago 35
C# Question

Invalid Expression Flag G Jquery

I am trying to use Jquery to load a partial view on my page but I keep getting this Invalid Expression Flag G error, I have no idea what it means.

Here is the code that I have created in my cshtml file:

.click(function() {
$('#detailsPlace').load(@Url.Action("GetDetails", "Home"));

<table class="table">
@foreach (var item in Model)
<a href="#" id="getDetails">@Html.DisplayFor(modelItem => item.Description)</a>

<div id="detailsPlace"></div>

This is the code inside my contoller:

public ActionResult Index()
ReferenceRepository test = new ReferenceRepository();

var response = test.GetParts("A");
return View(response);

public ActionResult GetDetails()
return PartialView();

This is just some dummy code in my PartialView:


When I look at the web console which is where I found the error and click on it it takes me to this line of code


this is code from the webpage and thats why it looks different to mine. My controller is actually called HomeController but it only expects Home for some reason


/Home/GetDetails is being interpreted as a regular expression, using "Home" as the pattern and "GetDetails" as the flags. That's an invalid regular expression, hence the error.

You should wrap it in quotes, like this::

$('#detailsPlace').load('@Url.Action("GetDetails", "Home")');