In Drupal, JavaScript files are added via the drupal_add_js()drupal_add_js()
function or in the
theme’s .info file.
A simple example of using jQuery in drupal is
<?php
drupal_add_js('jQuery(document).ready(function () {
jQuery.ajax({
url: '/code/test-ajax.php',
data: {'a':'hello','b':'world'},
type: 'POST',
success: function(data){
alert(data); //Should return "hello, world"
},
error: function(jqXHR, textStatus, errorThrown){
alert(textStatus + errorThrown); //Better diagnostics
}
});
});', 'inline');
?>
you have to use 'jQuery' instead of $.