The easiest way to integrate Social Login in your React Apps ...Checkout NPM

Monday, April 1, 2013

JQuery unrecognized expression in parsing MVC Partial

This is a quick tip sharing. Recently, I was stuck in a problem where I was making an AJAX call to get MVC partial as HTML in response.

Within this response, I made an attempt to find an element using $.find as following:

   url: theURL,
   type: "POST",
   success: function (data) {
                 var controls = $(data).find('#someTextBox'); }
.find threw an exception:
Uncaught Error: Syntax error, unrecognized expression: <HTML response>
Issue was with enter keys and spaces in the response. Trimming data before calling find, resolved the issue.

var controls = $(data.trim()).find('#someTextBox');