duanchui1251 2014-03-10 11:38
浏览 53
已采纳

Ajax响应没问题,但没有显示

In one of my web application I have a "Mark as Favorite icon". So when some one clicks on this button. It disappears and an ajax request is 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 the user id in database and returns a response with an icon "Remove Favorite". All this is working OK. Ajax response is

<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 this response in my google chrome Network tab. But the problem is this response doesn't display in the the div element with class .favh and remains empty. Please tell me where I am wrong. I am working in wordpress that's why I used

url: '<?php bloginfo('url') ?>/',

Here is my php code, that 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 this code is 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 only problem is not displaying this response.

  • 写回答

1条回答 默认 最新

  • douduidui1046 2014-03-10 11:56
    关注

    You're missing a " to close your class tag in your response.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 为什么eprime输出的数据会有缺失?
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题