Thursday, January 20, 2011

How to debug jQuery is getting properly loaded or not

 What is jQuery and why it is used?
 
jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. 
For details you can refer to http://jquery.com/

There are many Rails application in which I have used jQuery. Many times when jQuery is added to the application we aren't able to run it properly. Basic problem, how to debug jQuery, how to test whether jQuery is getting called or not?
To answer such questions, you can write the below codes in layout where you are including jQuery.

    <script type="text/javascript">
   $(document).ready(function() {
      alert("test");
   })
    </script>

Following codes will give you alert "test" when application is loaded. This way you can be sure where your problem lies.

No comments:

Post a Comment