卡片模块
drupal_add_js('jQuery(document).ready(function () {
currentRequest = $.ajax({
timeout:0,
cache: false,
url: pageUrl,
dataType: "json",
type: "GET",
success: function(data){
$("#edit-field-currency-type-und-0-value").val(data.currency);
}
});
ajax请求模块
$items['mccurr/%'] = array(
'title' => '',
'page callback' => 'ajax_currency_type',
'access arguments' => array('access content'),
'page arguments' => array(1),
'type' => MENU_SUGGESTED_ITEM,
);
function ajax_currency_type($ccode){
drupal_add_http_header('Content-Type', 'application/javascript; utf-8');
$query = "SELECT countries_country.currency
FROM countries_country
WHERE countries_country.iso2 = '".$ccode."'";
$data = db_query($query);
return drupal_json_encod($data);
}
这种方式返回json数据是否正确,否则我如何才能在我的car.module中获取返回数据。
谢谢你