title: Django/JQuery Syntax Error: I don't know why I am getting this error
body: <p>I am making a blog application using Django.
  In my <code>post_save()</code> function in <code>post_edit.js</code>, I have this post editt operation:</p>
  
  <pre><code>$.post(item.find("#post-form").attr("action") + "&amp;ajax" , data, function(result) {
      if (result != "failure") {
          item.before($("li", result));
          item.remove();
          $("ul.posts .edit").click(post_edit);
      }
  
      else {
          alert("Failed to validate post before saving")
      }   
  });
  </code></pre>
  
  <p>So after posting the blog data to my post_list.html template, the first line of the <code>if</code> block
  extracts <code>li</code> element from the result and inserts it before the "item" which is the original <code>li</code> element.</p>
  
  <p>The problem is, after this operation is done, I get a JQuery Syntax Error:</p>
  
  <pre><code>Error: Syntax error, unrecognized expression: 
      &lt;ul class="posts"&gt;
          &lt;li&gt;
              &lt;a href="/post/1" class="title"&gt;NEW POST&lt;/a&gt; 
              &lt;a href="/save/?id=1" class="edit"&gt;[edit]&lt;/a&gt; 
              &lt;br /&gt; Tags: 
  
              &lt;ul class="tags"&gt;
                  &lt;li&gt;
                      &lt;a href="/tag/tag1"&gt;tag1&lt;/a&gt;
                  &lt;/li&gt; 
                  &lt;li&gt;
                      &lt;a href="/tag/tag2"&gt;tag2&lt;/a&gt;
                  &lt;/li&gt; 
              &lt;/ul&gt; &lt;br /&gt; 
          &lt;/li&gt; 
      &lt;/ul&gt;
  </code></pre>
  
  <p>I am having trouble figuring out why I'm getting a syntax error, because the 
  <code>ul class="posts".../ul</code> block looks completely fine to me. After debugging, I am pretty sure that
  it is the 3rd line <code>(item.before($("li", result));)</code> that is causing the problem.</p>
  
  <p>Can someone please help me find the problem?</p>
  
  <p>Thank you</p>
  
  <p>+
  Also, there's another confusion. </p>
  
  <p>The "result" is the <code>ul</code> block:</p>
  
  <pre><code>ul class="posts"&gt;
      &lt;li&gt;
          &lt;a class="title" href="/post/1"&gt;NEWPOST&lt;/a&gt;
          &lt;a class="edit" href="/save/?id=1"&gt;[edit]&lt;/a&gt;
          &lt;br&gt; Tags:
  
          &lt;ul class="tags"&gt;
              ...
          &lt;br&gt;
      &lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>I thought the line <code>item.before($("li", result));</code> 
  is supposed to extract the "li" element from the result, but it looks like it is 
  returning the whole "ul" block...</p>