File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33<asp:Content ID =" content" ContentPlaceHolderID =" MainContent" runat =" server" >
44 <h3 >Ajax demo</h3 >
55
6- <%-- Setup place holder for Razor MVC view content--%>
6+ <%-- Setup placeholder for Razor MVC view content--%>
77 <div id =" razorViewContent" >
88 </div >
99
1010 <script type =" text/javascript" >
11- $ (function () {
12-
13- // Call MCV view on document completed
14- $ .ajax ({
15- type: " Get" ,
16- url: " /RazorDemo/SomeAjaxCall" ,
17- data: ' id=55' ,
18- success : function (document ) {
19- $ (' #razorViewContent' ).html (document );
20- }
21- });
22- });
23- </script >
11+ document .addEventListener (" DOMContentLoaded" , function () {
12+ // Call MCV view on document completed
13+ fetch (" /RazorDemo/SomeAjaxCall?id=55" , {
14+ method: " GET"
15+ })
16+ .then (response => {
17+ if (! response .ok ) {
18+ throw new Error (" Network response was not ok" );
19+ }
20+ return response .text ();
21+ })
22+ .then (documentHtml => {
23+ document .getElementById (" razorViewContent" ).innerHTML = documentHtml;
24+ })
25+ .catch (error => {
26+ console .error (" Fetch error:" , error);
27+ });
28+ });
29+ </script >
2430
2531</asp:Content >
2632
You can’t perform that action at this time.
0 commit comments