i have one module: wego, and i want to use ajax in wego.js which is located in wego/js/wego.js. The ajax needs send get request to get_data.php which is located in wego/get_data.php. My server setting is test.drupal.com. Here is my code:
jQuery(function() {
var $basepath = Drupal.settings.basePath;
//alert($basepath); outputs '/'
jQuery.get($basepath+'wego/get_search_id.php',function(data){
alert(data);
});
});
and i add this js file in wego.module:
function wego_init() {
drupal_add_js(drupal_get_path('module', 'wego') . '/js/wego.js');
}
Does anyone know why the get_search_id.php can not be found? The error message is:
http://test.drupal.com/wego/get_search_id.php can not be found
Its because you missed the forward slash after Drupal.settings.basePath in jQuery.get
It should be likes this