Q:

What's the error with my code?

I'm using smarty template and php. The following code is being written in smarty template.
{literal}
<script type="text/javascript">
// This function gets test when category checkbox is checked

function get_subjects_by_class(class_id) {
    var field_id = 'subjects';
    $.ajax({
        url: "teacher_details.php",
        type: "GET",
        data: {
            'request_type': 'ajax',
            'op': 'get_assigned_subject_list',
            'class_id': class_id
        },  
        success: function (data) {
            $('#category_test_container').append(data);
        });
    }
</script>
{/literal}

Call to this function is as follows :
<a href="#" onClick="get_subjects_by_class({$class.class_id}); return false;">{$class.class_name}</a>

Upon clicking on hyperlink I'm getting an error as follows :
ReferenceError: $ is not defined
$.ajax({

I googled it for the error resolution, but couldn't get the desired resolution. Can anyone help me out to resolve this error? Thanks in Advance.

A:

You either haven't loaded jQuery or you've loaded it after you've run this script.  This is why $ is undefined.

