2014-01-25 91 views
1

我有一個模塊:我的航班時刻表是位於wego.js的航空公司/ js/wego.js。 ajax需要發送get_data.php請求,它位於wego/get_data.php。我的服務器設置是test.drupal.com。這裏是我的代碼:drupal 7模塊js ajax獲取文件路徑

jQuery(function() { 
    var $basepath = Drupal.settings.basePath; 
    //alert($basepath); outputs '/' 
    jQuery.get($basepath+'wego/get_search_id.php',function(data){ 
     alert(data); 
    }); 
}); 

和我添加這個js文件中wego.module:

function wego_init() { 
    drupal_add_js(drupal_get_path('module', 'wego') . '/js/wego.js'); 
} 

有誰知道爲什麼get_search_id.php無法找到?該錯誤信息是:

http://test.drupal.com/wego/get_search_id.php can not be found 

回答

0

它,因爲你在jQuery.get

無緣正斜槓Drupal.settings.basePath後

應該是像這

jQuery.get($basepath + '/wego/get_search_id.php',function(data){ 
    alert(data); 
}); 
+0

感謝您的回覆,但它添加正斜槓後仍然不起作用。錯誤是:GET http://wego/get_search_id.php – user3210341