简体   繁体   中英

Ajax not working in drupal 6

in Form

$form['assignJob'] = array(
                    '#type' => 'checkbox',
                    '#title' => 'AssignJob',
                    '#default_value' => 1,
                    '#suffix'=>"<script>$js</script>"
            )

in $js i defined the JS.

                $js = <<<EOJS
Drupal.behaviors.checkboxrender = function(context) {
  $('#edit-assignJob', context).change(function(event, ui) {
     var method = $(this).val();
     if(method){
        $.get('/assignJob/',null,responseDetails);
     }

  });
  var responseDetails=function(response){
    alert(response);
  }

};
EOJS;

In hook_menu in defined the menu

$items['assignJob'] = array(
        'page callback' => 'assignee',
        'type' => MENU_CALLBACK,
        'access arguments' => array('access administration'),
    );
    return $items;

function assignee() {
    $output='xxxx';
    return drupal_json(array('status' => TRUE, 'data' => $output));
    drupal_exit();
}

So whenever i click on checkbox it return me the blank value. Can anybody help in this.?

When i render this i got warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'assignee' not found or invalid function name in C:\\Server\\www\\drupal-final\\includes\\menu.inc on line 350.

I'll try to help you . But all i know that what's responsible for Ajax call or javascript is the ahah property . have a read on drupal api http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/6#ahah

Also read this http://drupal.org/node/348475

By the way i never saw suffix that takes Script . i always use ahah property .

You can download this example http://www.kristen.org/content/drupal-ahah-form-examples

and read this article http://fuseinteractive.ca/blog/how-create-custom-drupal-ajax-module-0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM