Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firefox add <a xmlns="http://www.w3.org/1999/xhtml">

EDIT: 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;

If I do:

jQuery(selector).html(valueToDisplay);

I get:

<p><a xmlns="http://www.w3.org/1999/xhtml">test</a></p>

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.

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>

However when I use jQuery(selector).html to insert it inside of an existing anchor

I get:

<p><a xmlns="http://www.w3.org/1999/xhtml">Passport Photo</a></p>

I have been trying to figure out where that xmlns anchor is added but can't narrow it down to anything specific.

EDIT: I have tried forcing dataType:"html" in the ajax call...no change.

like image 663
jfrobishow Avatar asked Sep 17 '10 14:09

jfrobishow


People also ask

What is xmlns http www w3 org 1999 xhtml?

The xmlns attribute specifies the xml namespace for a document. Note: The xmlns attribute is required in XHTML, invalid in HTML 4.01, and optional in HTML5.

What is HTML namespace?

A Namespace is a set of unique names. Namespace is a mechanisms by which element and attribute name can be assigned to a group. The Namespace is identified by URI(Uniform Resource Identifiers).


1 Answers

Your selector represents something that is, or is in an a tag.

A much more minimal version of your problem would be:

html:

<a id="test"></a>

js:

$('#test').html('<p>test</p>');

result:

<a id="test"><p><a xmlns="http://www.w3.org/1999/xhtml">test</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>');
like image 102
Conley Owens Avatar answered Nov 12 '22 19:11

Conley Owens