Firefox添加< a xmlns =" http://www.w3.org/1999/xhtml"> [英] Firefox add <a xmlns="http://www.w3.org/1999/xhtml">
问题描述
编辑:由于ajax调用,这种情况没有发生。我改变它以使用来自TinyMCE组件的值来获得乐趣,我得到同样的东西。
This isn't happening because of the ajax call. I changed it to use a value from a TinyMCE component for fun and I get the same thing.
content = tinyMCE.get('cComponent').getContent(); //content at this point is <p>test</p>
valueToDisplay = content;
如果我这样做:
jQuery(selector).html(valueToDisplay);
我得到:
<p><a xmlns="http://www.w3.org/1999/xhtml">test</a></p>
在使用Firefox 3.6之前,有没有人见过这个。 10和jQuery 1.4.2,我试图使用jQuery ajax调用的结果更改链接文本。
Has anyone ever seen this before using Firefox 3.6.10 and jQuery 1.4.2, I am trying to change a link text using the result from a jQuery ajax call.
我得到了ajax调用的预期结果:
I get the result expected from the ajax call:
function getValueToDisplay(fieldType){
var returnValue;
jQuery.ajax({
type: "GET",
url: "index.cfm",
async:false,
data: "fieldtype="+fieldType,
success:function(response){
returnValue = response;
}
});
return returnValue;
}
如果我此时检查值,我会得到预期值
If I check the value at this point I get the expected value
console.log(returnValue) //output this --> <p>Passport Photo</p>
然而,当我使用jQuery(选择器).html将其插入现有锚点
However when I use jQuery(selector).html to insert it inside of an existing anchor
我得到:
<p><a xmlns="http://www.w3.org/1999/xhtml">Passport Photo</a></p>
我一直在试图找出添加xmlns锚点的位置,但无法将其缩小到任何特定的。
I have been trying to figure out where that xmlns anchor is added but can't narrow it down to anything specific.
编辑:我在ajax调用中尝试强制dataType:html...没有变化。
I have tried forcing dataType:"html" in the ajax call...no change.
推荐答案
您的选择器表示的内容是 a
标记。
Your selector represents something that is, or is in an a
tag.
问题的最小版本将是:
html:
<a id="test"></a>
js:
$('#test').html('<p>test</p>');
结果:
<a id="test"><p><a xmlns="http://www.w3.org/1999/xhtml">test</a></p></a>
改变一切,这样你就不会把 p
a
标记中的标记,或执行以下操作:
Change things around so you aren't putting p
tags in an a
tag, or do the following:
$('#test').empty().append('<p>test</p>');
这篇关于Firefox添加< a xmlns =" http://www.w3.org/1999/xhtml">的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!