Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7801929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:06:02+00:00 2026-06-02T01:06:02+00:00

I have a file- Site.js with the following method: function Init() { $(document).ready(function() {

  • 0

I have a file- “Site.js” with the following method:

function Init() {
  $(document).ready(function() {
    //some init actions here
  });
}
function jQuery.fn.DivToggle(div) {
  $(div).toggle('fast');
  //some other animation code here
}

in my Index.cshtml file (I’m using asp.net mvc), I have this:

<!DOCTYPE html>
<html>
  <head id="Head1" runat="server">
    <script src="@Url.Content("~/Scripts/jquery-1.7.1.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/Site.js")" type="text/javascript"></script>
  </head>
  <body>
    <script type="text/javascript">
      $(function () {
        Init();
      });
    </script>
  </body>
</html>

I get this error when I run the project:
“Microsoft JScript runtime error: ‘Init’ is undefined”

Any idea what I’m doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T01:06:05+00:00Added an answer on June 2, 2026 at 1:06 am

    Init is not defined because there is a syntax error in Site.js.

    function jQuery.fn.DivToggle(div) {
      $(div).toggle('fast');
      //some other animation code here
    }
    

    You can’t actually do that. It should be:

    jQuery.fn.DivToggle = function(div) {
      $(div).toggle('fast');
      //some other animation code here
    };
    

    P.S. $(function(){ is the same as $(document).ready(function(){. You don’t need the $(document).ready(function(){ inside your Init function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<script type=text/javascript> $(document).ready(function() { $(ul.productSmall).sfProductFilter(); alert(jQuery is working fine!); }); </script> I have above
I have the following code in a web.config file of the default IIS site.
I have the following controller file: <?php class Test extends CI_Controller { function __construct()
I have the following web service method (.ASMX file): [WebMethod(EnableSession = true)] [ScriptMethod(ResponseFormat =
I have a file hosting site that's using this script MFHS . I want
I have an mp3 file in my site. I want to output it as
I have a php file at my site, and I connect to db, get
I have a swf file on my site and it doesn't work on Iphone/Ipad
I have a file download code in my site which worked perfectly fine untill
I have a system for a file hosting site which requires a PHP script

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.