file mymodule.inc :
$items['ajax/channel/%/get-program'] = array(
'title' => t('get channel program by ID'),
'type' => MENU_CALLBACK,
'page callback' => 'get_channel_program',
'page arguments' => array(2),
'access arguments' => array('access content'),
);
return $items;
//channel program
function get_channel_program($channel_id){
$channel_id = (isset($_POST['channel_id']) ? $_POST['channel_id'] : '');
if (!is_numeric($channel_id)) :
drupal_not_found();
else :
drupal_json_output($channel_id);
endif;
}
file mudule.js :
Drupal.behaviors.ajaxProgram = {
attach: function (context, settings) {
// CSS Selector for the button which will trigger the AJAX call
$('.channel-tv-tabs .tab .tabset .single-prog', context).click(function () {
var channel_id = $(this).data('channel-id');
$.ajax({
url: '/'+Drupal.settings.pathPrefix + 'ajax/channel/'+channel_id+'/get-program', // This is the AjAX URL set by the custom Module
type: "POST",
data: { channel_id : channel_id }, // Set the number of Li items requested
dataType: "json", // Type of the content we're expecting in the response
success: function(data) {
var parsed_data = $.parseJSON(data);
console.log(parsed_data); // Place AJAX content inside the ajax wrapper div
},
error: function(jqXHR, textStatus, errorThrown){
console.log(errorThrown);
}
});
});
}
};
Pls help me and tell what i do wrong?