Click here to Skip to main content
15,893,644 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear all,

I have the following jquery file name queryValidate.js
This is the function inside the file:
C#
function YesNoDialogBox(button1, button2, element) {
    var btns = {};
    btns[button1] = function () {
        alert("yes");
    };
    btns[button2] = function () {
        // Do nothing
        alert("No");
        $(this).dialog("close");
    };

    $("<div></div>").dialog({
        autoOpen: true,
        title: 'Confirmation Box',
        modal: true,
        buttons: btns
    });
}

$('#btnSubmitchanges').click(function () {
    YesNoDialogBox('Yes', 'No', $(this));
})


in the HTML code:

<script src="queryValidate.js" type="text/javascript"></script>
and for that I have added one click button:
XML
<div class="buttonHolder">
                 <input name="Button3" id="btnSubmitchanges" type="button" value="Submit Changes" style="background-color:#A9E2F3; font-size: 12px; font-weight:bold;"  />
</div>


Now, every time I click I got the error:
JavaScript runtime error: '$' is undefined
I saw that there is need to add reference to jquery library but I could not do that. How to fix the attached error?

BR//Hussain
Posted

You probably have not added a reference to the core jQuery library, try add it to the header like this:
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>

Refer:
1. Downloading jQuery[^]
2. Getting started with jQuery[^]
 
Share this answer
 
v2
Comments
Thomas Daniels 20-Feb-15 6:41am    
+5
Peter Leow 20-Feb-15 8:01am    
Thank you, ProgramFOX.
You can find paths for whichever version of JQuery you need here[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900