Skip to content

Commit 8b634e6

Browse files
committed
[FIXED] javascript
1 parent 7f6e36c commit 8b634e6

1 file changed

Lines changed: 20 additions & 14 deletions

File tree

YAF.SampleWebApplication/AjaxDemo.aspx

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,30 @@
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

0 commit comments

Comments
 (0)