php - Receiving empty data on ajax request in spite of available data -
i trying sub-category list of category ajax request through admin-ajax.php
. categories under custom post type. each category has sub categories. ajax request returns no data in console
.
jquery.ajax({ type: 'post', url: classipress_params.ajax_url + "?action=dropdown-child-categories", datatype: "json", data: { cat_id : category_id }, //show loading when dropdown changed beforesend: function() { ... }, //stop showing loading when process complete complete: function() { ..... }, error: function(xmlhttprequest, textstatus, errorthrown){ .... }, // if data retrieved, store in html success: function( data ) { // child categories found build , display them if ( data.success === true ) { console.log(data); .... } } });
am doing wrong? category_id
okay, tested that. result in console:
{ success: true, html: "" }
try changing action hook name :
add_action( 'wp_ajax_nopriv_cp_addnew_dropdown_child_categories', 'cp_addnew_dropdown_child_categories' ); add_action( 'wp_ajax_cp_addnew_dropdown_child_categories', 'cp_addnew_dropdown_child_categories' );
Comments
Post a Comment