JQuery AJAX loading fails on ASP.NET MVC Controller Action

I have a simple thing: two divs and two calls to load partial files (controller actions with PartialView as results).

I am dealing with two controller actions: Index and ItemDetail. JQuery loading works in the view returned by the index action, but not in the ItemDetail.

These elements are located in one controller, and you can access them in a browser as follows: http: // [site] / items http: // [site] / items / itemdetail

To isolate the problem, I configured Index and ItemDetail to return views with the same syntax:

<div id="deptTickets">Loading department tickets...</div>
<div id="recentTickets">Loading recent tickets...</div>

<script type="text/javascript" language="javascript">
    $("#deptTickets").load("items/DepartmentTickets");
    $("#recentTickets").load("items/RecentTickets");
</script>

The .load methods start and load the corresponding partial views for the index, but not for ItemDetail.

, . , "" , jQuery, "index" itemDetail, , jQuery.

?

+3
2

URL- , . , Url.

<script type="text/javascript" language="javascript"> 
    $("#deptTickets").load("<%= Url.Action( "DepartmentTickets", "Items" ) %>"); 
    $("#recentTickets").load("<%= Url.Action( "RecentTickets", "Items" ) %>"); 
</script>
+2

URI, URI. , AJAX, , 404. Firebug net Fiddler, .

+1

Source: https://habr.com/ru/post/1728183/


All Articles