jQuery html()和& amp; amp; amp; amp; amp; amp; [英] jQuery html() and &

查看:124
本文介绍了jQuery html()和& amp; amp; amp; amp; amp; amp;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在人名列表中搜索。我希望它能够在飞行中显示结果,所以它确实如此。但有一个我需要的链接,它应该是这样的:

  chatid = 18& userid = 45& create = new 

但是结果显示为:

  $。get('/ ajax.php',{sec:'search_users',ajax:1,search_for:$(this).val()},function(data) 
{
$(。rBoxContentStaff)。html(data);
});

我得到以下结果:

  chatid = 18& amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; p>并且链接不起作用。这似乎发生在html()和append()中。



我没有找到解决方案,所以我不得不改变链接的触发。 / b>

解决方案

而不是这样做:

  $( rBoxContentStaff。)HTML(数据)。 }); 

试试这个:

  $( rBoxContentStaff)附加(数据); }); 

text()转义html字符...我找不到任何关于 html()转义字符(实际上,它的文档似乎表明不是。)
然而,在用jmein的建议测试alert后,它会对特殊字符进行编码,Append()不会所以。


I'm doing a search within list of people. And I want it to show results on the fly and so it does. But there is one link that I need and it should look like this:

chatid=18&userid=45&create=new

but after the results are displayed through this:

$.get('/ajax.php', {sec: 'search_users', ajax: 1, search_for: $(this).val()}, function(data)
{
    $(".rBoxContentStaff").html(data);
});

I get this result:

chatid=18&userid=45&create=new

And the link doesn't work. This seems to happen in html() and also append().

I found no solution for this so I had to change the triggering of the link.

解决方案

Instead of doing this:

$(".rBoxContentStaff").html(data); });

Try this:

$(".rBoxContentStaff").append(data); });

text() escapes html characters ... I can't find anything about html() escaping characters (and indeed, its documentation seems to indicate otherwise.
However, after testing with alert at jmein's suggestion, it does encode special characters. Append() does not do so.

这篇关于jQuery html()和& amp; amp; amp; amp; amp; amp;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆