drupal ajax json异步调用.docx_第1页
drupal ajax json异步调用.docx_第2页
drupal ajax json异步调用.docx_第3页
drupal ajax json异步调用.docx_第4页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

drupal ajax json异步调用模块文件结构: sitemode.module test_; $Id$name = Sitemoddescription = A content type for jokes.package = Pro Drupal Developmentcore = 6.xsitemode.module sitemod_callback_ajax, access arguments = array(access content), type = MENU_CALLBACK, ); $itemstest/ajax = array(/调用form效果 见下图 page callback = drupal_get_form, page arguments = array(get_ajax_form),/ 得到定义好的表单 access arguments = array(access content), type = MENU_CALLBACK, ); return $items;function get_ajax_form()/返回form选选项 drupal_add_js(drupal_get_path(module, sitemod) . /test_ajax.js);/加载js文件 $formnote_book = array( #type = radios, #title = t(选择分类), #default_value = IBM, #options = array(t(IBM), t(Dell), t(Sony),t(HP), #description = t(选择你喜欢的品牌), ); return $form;function sitemod_callback_ajax() $id = $_POSTid; /ajax post数据switch($id) case 0: drupal_json(array(html = drupal_get_form(ibm_form);/josn数据。form exit; break; case 1: drupal_json(array( html = drupal_get_form(dell_form); exit; break;function ibm_form()/定义表单 $formibm = array( #type = checkboxes, #title = t(IBM最新型号电脑), #default_value = array(T410), #options = array( T400 = t(T400), T410 = t(T410), X200 = t(X200), X201 = t(X201), T410S = t(T410S), ), #description = t(选择你喜欢的IBM型号), ); $formsubmit = array( #type = submit, #value = t(保存选择的信息), #weight = 40, ); $form_stateredirect = test/view;return $form;function dell_form()/定义表单 $formdell = array( #type = checkboxes, #title = t(Dell电脑), #default_value = array(d1), #options = array( d1 = t(d1), d2 = t(d2), d3 = t(d3), ), #description = t(选择你喜欢的dELL型号), ); $formsubmit = array( #type = submit, #value = t(保存选择的信息), #weight = 40, );return $form;/返回表单test_ajax.js if(Drupal.jsEnabled) $(document).ready(function () $(input:radioname=note_book).click(function () var getSubmit = function(data) $(#footer).html(data.html); $.ajax( type: POST, url: /drupal/ajax, dataType: json, success: function(msg) /alert(

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论