Monday, 16 April 2012

$ is not defined in the javascript error console


I have implemented the jqeury onclick event as below

$(function () {
            $('#radio_button').click(function(){
                     alert('alert me');
                     $.ajax({
                            type : 'get',
                            url : '/check_things?format=json',
                            datatype : 'json',
                            headers: {
                                 'X-Transaction': 'POST Example',
                                 'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
                               },
                            success : function(data) {
                            },
                            error : function(data){
                            }
                          });
                 });

          });


When I load the page, I used to get '$ is not defined' in the Error console of my firefox browser.

After making some research, I came to see its been due to issue with jquery files.

We need to load the required jquery files before the script functional call. So I have copied the javascript files from the bottom of the page to header part of the page.

Now the Error console was clear and I am able to get the alert message when I click on the radio button.


Thank You,
Uma Mahesh

No comments:

Post a Comment