Unrecognized jQuery expression in Ajax answer

I have this form of jQuery Ajax.

$('#modal-body-sign-in').on('submit', '#sign-in', function(e) {
        e.preventDefault();
        var data = $(this).serialize();
        var url = $(this).attr('action');
        $.ajax({
            //this is the php file that processes the data and send mail
            url : url,
            type : "POST",
            data : data,
            dataType: "html",
            //Do not cache the page
            cache : false,
            //success
            success : function(data) {
                //console.log(data.content);

                console.log($(data));
                //$('#modal-body-sign-in').html(data);
            }
        });
    })

in the answer, when I console.log(data); in the console it shows me the responded html, but when I do this console.log($(data));, he gives me this error

Search error: syntax error, unrecognized expression:

<html>
<head>
<style>
ul {
    margin: 0%;
}

ul li {
    display: inline;
    list-style-type: none;
    float: left;
}
</style>
<title>Insert title here</title>
</head>
<body>
    <!--  Ajax Container. DO NOT REMOVE THE DIV CONTENT  FOR AJAX ACCESS! -->
    <div id="content">
        <div id="modal-body">

            <form id="doLogin" name="doLogin" action="/HitPlay/doLogin" method="post">

                <fieldset>
                    <ul id="doLogin_" class="errorMessage">
            <li><span>Incorrect username or password</span></li>    </ul>

                <br/>           

                <br/>

                    <label>Username</label>                 
                    <input type="text" name="userBean.username" value="" id="doLogin_userBean_username"/>
                    <br/>
                    <label>Password</label>
                    <input type="password" name="userBean.password" id="doLogin_userBean_password"/>
                    <br />

                    <input type="submit" id="doLogin_0" value="Submit"/>

                </fieldset>
            </form>





        </div>

    </div>
</body>
</html> jquery-1.9.0.min.js:2
a.error jquery-1.9.0.min.js:2
f jquery-1.9.0.min.js:2
x jquery-1.9.0.min.js:2
a jquery-1.9.0.min.js:2
st.fn.extend.find jquery-1.9.0.min.js:2
st.fn.st.init jquery-1.9.0.min.js:1
st jquery-1.9.0.min.js:1
$.ajax.success localhost:59
f jquery-1.9.0.min.js:1
p.fireWith jquery-1.9.0.min.js:1
r jquery-1.9.0.min.js:3
r

I did it

  $(data) 

because I want to receive a fragment of the responding HTML page

+2
source share
2 answers

I have exactly the same problem since I upgraded to jQuery 1.9.x. in fact, simple $ (data) generates a crash, nothing more. I had this problem several times earlier (without previous versions than 1.9), but I do not remember its problem ...

in any case, this is a completely blocking problem ... still looking for the cause of this and a fix.

EDIT:

If I do this:

$.ajax('/',function(html){
  html = $('<div></div>').append(html);
  $(html);
});

It works great. If I do this:

$.ajax('/',function(html){
  $(html);
});

( FF):

Erreur : Error: Syntax error, unrecognized expression: <div id="...">(...)
jquery.min.js - line : 4

2:

... : http://stage.jquery.com/upgrade-guide/1.9/#jquery-htmlstring-versus-jquery-selectorstring

, - :

$.ajax('/',function(html){
  $($.parseHTML(html));
});

jQuery ,

+17