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:
Within this response, I made an attempt to find an element using $.find as following:
$.ajax({ 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');
No comments :
Post a Comment
What are your thoughts on this post? Did you like it?