weixin_33738578 2018-01-03 11:58 采纳率: 0%
浏览 52

Drupal 7 Ajax调用

I'm beginner with drupal, I use drupal 7.x and I would like to create a simple ajax call.

I have a template file and I have a button in it with a javascript function in onclick method.

<input type='button' onclick='doajax()'>
<div id='ajaxresponsediv'></div>

In the js file:

function doajax()
{
   jQuery.get(url,function(data) {
   jQuery("#ajaxresponsediv").html(data);
});
}

Ok it's a simple thing. But what do I have to code in .module file ? What will be the url variable in my code? How do I implement the callback function (for example I would like to print simply 'Hello' into ajaxresponsediv ) ? Do I have to register something in mymodule_menu() function? Thanks for the guidelines.

  • 写回答

1条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 有偿找一份verilog语言的cnn代码带讲解
      • ¥15 关于#mysql#的问题:mysql 组内排名,取各组的销售金额前10
      • ¥15 有人用过颜色传感器吗?
      • ¥50 求一个SQL长料切短料的优化排版算法
      • ¥15 python 删除TXT文档中小写字母
      • ¥15 ValueError: not enough values to unpack (expected 2, got 0)
      • ¥15 js怎么禁止修改域名
      • ¥15 Cursor为什么在Windows11打不开
      • ¥30 java调用javacv遇到的问题
      • ¥15 如何使用matlab画出带宽100Khz,时长100ms信号的LFM形式的时频图啊