php - Ajax response is OK but not displaying -
in 1 of web application have "mark favorite icon". when 1 clicks on button. disappears , ajax request called
jquery('.favr').click(function() { var user_ids = jquery(this).attr('id'); var current_ids = '<?php echo $cui ?>'; jquery.ajax({ url: '<?php bloginfo('url') ?>/', type: 'post', data: {'ajaxreturn': '102', 'logedid': current_ids,'ids':user_ids}, success: function(result) { jquery('.favh').html(result); } }); });
which inserts user id in database , returns response icon "remove favorite". working ok. ajax response
<i data-tooltip="" data-selector="tooltip0d27op" title="remove favorite" class="has-tip tip-left radius icon-heart-empty orange favr-'. $userid .' id='. $userid.' ></i>
i can see response in google chrome network tab. problem response doesn't display in the div element class .favh , remains empty. please tell me wrong. working in wordpress that's why used
url: '<?php bloginfo('url') ?>/',
here php code, ajax calls
add_action('init','my_ajaxreturn_102'); function my_ajaxreturn_102(){ if ($_post['ajaxreturn'] == 102) { $userid = $_post['ids']; $loggedid = $_post['logedid']; $rem_array = json_decode(get_user_meta($loggedid, 'meta_favorite', true), true); $fav_array = array_unique($rem_array); $searched_item = array_search($userid,$fav_array); unset($fav_array[$searched_item]); update_user_meta( $loggedid, 'meta_favorite', json_encode($fav_array)); echo '<i data-tooltip="" data-selector="tooltip0d27op" title="remove favorite" class="has-tip tip-left radius icon-heart-empty orange favr-'. $userid .' id='. $userid.' ></i>'; exit; } }
all code working fine, sending response
<i data-tooltip="" data-selector="tooltip0d27op" title="remove favorite" class="has-tip tip-left radius icon-heart-empty orange favr-'. $userid .' id='. $userid.' ></i>
but problem not displaying response.
you're missing "
close class tag in response.
Comments
Post a Comment