views:

60

answers:

1

This two errors I get in the Firefox error console:

Error: Incorrect document format
Source file: 
Row 1, column 45
Source code:
<div xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;

Error: uncaught exception: [Exception... "An invalid or illegal string was specified"  code: "12" nsresult: "0x8053000c (NS_ERROR_DOM_SYNTAX_ERR)"  location: "http://127.0.0.1/WebLibThirdParty/JavaScript//jquery.js Line: 112"]

My jquery code is simple:

$(document).ready(function() {
        // when the #guest_details is clicked
    $('#guest_details').click(function() {

        var postedData = $('#guest-details-dialog-contents form').serialize();
        var uri = '/';
        $.ajax({
            type: 'POST',
            data: postedData,
            url: uri,
            success: function(data) {
                // this works
                            alert(data);
                            // this doesn't work
                alert($(data).html());
            }
        });

        return false;

    });
});

As you can see, the problematic line is:

alert($(data).html());

In the ajax callback. The PHP script returns valid XHTML (served as XML) so I am buffled by this issue.

EDIT:

Ok. The problem is that AJAX returns messed up XHTML. It changes tags to HTML:

<br /> becomes <br>
<input type="text" name="someInput" /> becomes <input type="text" name="someInput">
and so on
A: 

I really don't think the messed up XHTML is the problem. From the jquery documentation ( http://api.jquery.com/html/ ) for the html() method: This method is not available on XML documents. So if you're returning XML, that may be your problem.

A. M.
I tried returning XML, HTML, JSON, text...
Richard Knop
Are you sure it's not some other script that's interfering with this? From what I can see, it should work.
A. M.