1

Sorry for asking this question as this is ask many times before regarding Microsoft JScript runtime error: '$' is undefined error. I have my last project with working jquery and when i copy paste my code/.js to new project i got this error.

I know that this error occurs when .js is not reference on head tag but i am sure that i have my referenced my .js on my masterpage.

When i try to run developer tool(F12) and check on the scripts if it is loaded, this error shows

<html>
<head>
    <title>The resource cannot be found.</title>
    <style>
        body { font-family: "Verdana"; font-weight: normal; font-size: .7em; color: black; }
        p { font-family: "Verdana"; font-weight: normal; color: black; margin-top: -5px; }
        b { font-family: "Verdana"; font-weight: bold; color: black; margin-top: -5px; }
        H1 { font-family: "Verdana"; font-weight: normal; font-size: 18pt; color: red; }
        H2 { font-family: "Verdana"; font-weight: normal; font-size: 14pt; color: maroon; }
        pre { font-family: "Lucida Console"; font-size: .9em; }
        .marker { font-weight: bold; color: black; text-decoration: none; }
        .version { color: gray; }
        .error { margin-bottom: 10px; }
        .expandable { text-decoration: underline; font-weight: bold; color: navy; cursor: hand; }
    </style>
</head>
<body bgcolor="white">
    <span>
        <h1>
            Server Error in '/' Application.<hr width="100%" size="1" color="silver">
        </h1>
        <h2>
            <i>The resource cannot be found.</i>
        </h2>
    </span><font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif "><b>Description: </b>HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
        <br>
        <br>
        <b>Requested URL: </b>/Pages/Scripts/jquery-1.7.2.js
        <br>
        <br>
        <hr width="100%" size="1" color="silver">
        <b>Version Information:</b>&nbsp;Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272 </font>
</body>
</html>
<!-- 
[HttpException]: File does not exist.
   at System.Web.StaticFileHandler.GetFileInfo(String virtualPathWithPathInfo, String physicalPath, HttpResponse response)
   at System.Web.StaticFileHandler.ProcessRequestInternal(HttpContext context, String overrideVirtualPath)
   at System.Web.DefaultHttpHandler.BeginProcessRequest(HttpContext context, AsyncCallback callback, Object state)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
-->

But when i run my previous project with working jquery(same .js version with same folder structure) this is what is shows when i hit developer tool

/*!
 * jQuery JavaScript Library v1.7.2
 */

(function( window, undefined ) {

// Use the correct document accordingly with window argument (sandbox)
var document = window.document,
    navigator = window.navigator,
    location = window.location;
var jQuery = (function() {
// Define a local copy of jQuery
var jQuery = function( selector, context ) {
      // The jQuery object is actually just the init constructor 'enhanced'
      return new jQuery.fn.init( selector, context, rootjQuery );
    },
    //Etc etc.............

Heres my markup code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head runat="server">
    <title>EDI Service</title>
    <link href="../Contents/Styles/Site.css" rel="stylesheet" type="text/css" />
    <script src="../Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="../Scripts/jquery.blockUI.js" type="text/javascript"></script>
    <script src="../Scripts/jquery-1.7.2.js" type="text/javascript"></script>
    <asp:contentplaceholder id="HeadContent" runat="server">
    </asp:contentplaceholder>
    <script type="text/javascript">
        //MENU HIDE/SHOW TOGGLE
        function hideMenu() {
            var elem = document.getElementById('menu'); elem.style.display = 'none';
        }
        function showMenu() {
            var menu = document.getElementById('menu'); menu.style.display = 'block';
            var contents = document.getElementById('div-contents'); contents.style.display = 'block';
        }
    </script>
</head>

Any kind of help would be appreciated.

5
  • Are your scripts in /Pages/Scripts or /Scripts? Change your paths to be /Scripts instead of ../Scripts Commented May 17, 2013 at 3:38
  • Thank you for your reply Phill, my .js is now reference in my project however. i have this new error Microsoft JScript runtime error: Object doesn't support this property or method Commented May 17, 2013 at 3:46
  • i just figure it out.. the error seems on the two .js file. just remove <script src="../Scripts/jquery-1.7.2.js" type="text/javascript"></script> and it works like a charm.. Thank you Phill Commented May 17, 2013 at 3:59
  • 1
    Yes you don't need both the "min" jquery js and the other, you only need one or the other. The "min" js is packed meaning it is smaller and faster for clients to load. Commented May 17, 2013 at 13:52
  • @mikey nice catch, I didn't even notice that. Commented May 18, 2013 at 6:45

1 Answer 1

1

Please make sure that path of script file is correct. Because ../Script/jquery-1.4.1.min.js mean that your script file exist in 2 more level outside in hierarchy than your page.

for eg.

  1. First Lets assume project structure

    • Solution->Project->Script
    • Solution->Project->Default.aspx

    than your page and Script folder are at same level in hierarchy. So path must be "Script/jquery-1.7.2.min.js"

  2. Now assume this project structure

    • Solution->Project->Script
    • Solution->Project->Default->Default.aspx

    Because here script folder is one level up in hierarchy. So path on Default.aspx to add the script must be "./Script/jquery-1.7.2.min.js"

Thus be careful about accessing the path of your project files.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.