drupal 7模块js ajax获取文件路径
我有一个模块:wego,我想在wego.js中使用ajax,它位于wego/js/wego.js中。ajax需要发送get请求以获取位于wego/get_data.php中的_data.php。我的服务器设置是test.drupal.com。这是我的密码:drupal 7模块js ajax获取文件路径,ajax,drupal-7,drupal-modules,drupal-ajax,Ajax,Drupal 7,Drupal Modules,Drupal Ajax,我有一个模块:wego,我想在wego.js中使用ajax,它位于wego/js/wego.js中。ajax需要发送get请求以获取位于wego/get_data.php中的_data.php。我的服务器设置是test.drupal.com。这是我的密码: jQuery(function() { var $basepath = Drupal.settings.basePath; //alert($basepath); outputs '/' jQuery.get($bas
jQuery(function() {
var $basepath = Drupal.settings.basePath;
//alert($basepath); outputs '/'
jQuery.get($basepath+'wego/get_search_id.php',function(data){
alert(data);
});
});
我在wego.module中添加了这个js文件:
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
这是因为您错过了jQuery.get中Drupal.settings.basePath之后的正斜杠 应该是这样的
jQuery.get($basepath + '/wego/get_search_id.php',function(data){
alert(data);
});
谢谢你的回复,但在我添加正斜杠后仍然不起作用。错误是:获取