New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the Community Exchange, where community members ask and answer questions about DNN. To get started, just start typing your question below and either select one of the suggested questions or ask a new question of your own.

Load Razor File Using AJAX

Return to previous page

  • 6/25/2014
  • 4744 Views

Question:

Jeff Rogers long time ago

I'm trying to load a .CSHTML file using jQuery AJAX functionality. I have a small database application and I'm using DNN's Razor Host module. I want to avoid page load flicker and have the application fully loaded before it is displayed.  I've tried the following, which works for standard .HTML files, but not for .CSHTML files.  I get no errors when using this code, but nothing displays.  Any help would be appreciated.

<html lang="en">

<head>

<meta charset="utf-8" />

<title>Razor AJAX</title>

<script>

$(function () {

$('#MyContent').load('/_MyFile.cshtml');

})

</script>

</head>

<body>

<div id="MyContent">

</div>

</body>

</html>

Load Razor File Using AJAX

Jeff Rogers
Jeff Rogers long time ago
Add an Answer

Answers

Sign In to Participate
Or register to become a member