zoukankan      html  css  js  c++  java
  • [Drupal] My method of using ajax in Drupal

    That is just my method to create the ajax module. Here I will build a module "myajax" and locate it in sites/all/modules/


    1. Create the .info file, insert the content as below.

    ;$Id$
    name
    = My Ajax Module
    description
    = This is a module which is used when you can do with ajax in the server.
    core
    = 6.x
    version
    = "6.x-1.7"

    2. Create the .module file, inster the code as below.

    代码
    <?php
    /**
    * @file
    * My Ajax Module
    *
    * This is a module which is used when you can do with ajax in the server.
    *
    */
    function myajax_menu() {
    $items = array();

    $items['insertsth'] = array(
    'page callback'=>'myajax_insertsth',
    'access callback'=>TRUE,
    'type'=>MENU_CALLBACK,
    );
    return $items;

    }

    function myajax_insertsth () {
    //In this function, you can handle with the parameters sent from the client.

    //Use $_GET

    var_dump($_GET);

    //use $_POST
    var_dump($_POST);


    //REMEMBER that after you handing with the data, use the die() to stop to load the whole page.
    die();
    //echo "Hello, world!";die();
    }

    3. Test now!
    Now you can insert a test url, such as http://www.example.com/myajax/111, then you can see the result.
    Of course, you can create a form, and post the data to the url.


    If you have any good idea about how to use ajax in Drupal, please tell me!  :)

  • 相关阅读:
    asp.net Post Get提交数据转Model实例
    ETL构建数据仓库五步法
    什么是数据仓库-数据仓库的基本概念
    简单的说下什么是数据仓库
    简单理解Socket
    Net中的反射使用入门
    JS---BOM
    jQuery Ajax 全解析
    Ajax与JSON的一些总结
    ASP.NET中验证控件的使用
  • 原文地址:https://www.cnblogs.com/davidhhuan/p/1799796.html
Copyright © 2011-2022 走看看