javascript - ajax jquery and drupal not work, please see why -


drupal 6: here code: http://pastebin.com/ggvffags

//getcity.js: $(document).ready(function() {     $("#edit-field-house-geo-area-value").bind('change', function(){          selected_loc=$("#edit-field-house-geo-area-value option:selected").val();         var myurl="http://whatever.com/getajax/citys/"+selected_loc+"/";         $.ajax({              type: "get",              url: myurl,              datatype: "json",              success: function(data){             console.log(data);              }             });      }); }); 

drupal module:

function sf_menu() {   cache_clear_all();   $items = array ();   $items ['getajax/citys/%'] = array ('title' => 'this custom page', 'page callback' => 'sf_get_cities_ajax', 'access arguments' => array ('access content' ), 'access callback' => 'user_access', // true give access 'page arguments' => array (2 ), 'type' => menu_callback );   return $items; }    function sf_get_cities_ajax($cityid) {   $termsarray = array ();   $terms = array ();   $cityid_safe = (int)$cityid;   $cityid_safe = check_plain($cityid_safe);   if (is_number($cityid_safe)) {     $terms = taxonomy_get_children($cityid_safe, 143, 'tid');     if (count($terms)) {       foreach ($termsarray $k => $v) {         $termsarray [check_plain($k)] = t($v [tid]);       }      $f= array('status' => 1, 'data' => $termsarray,'moo'=>'sadasdsd');     print drupal_json($f);      exit();     }    } } 

its not return me somthing print 'moo' data


its function working fine array @ final dont pass

that looks should work except 1 thing... php doesn't have function 'is_number()' unless wrote own need change if statement use php built in 'is_numeric':

if (is_numeric($cityid_safe)) { 

its not js issue @ all.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -