Search code examples
javascriptjquerydwr

Jquery "greater than" symbol


When I use below notation with '>' in line

$('#tablesorter > tbody')

in code

var message;
myService.getUsers({ callback : function(str) { 
    message= jQuery.parseJSON(str);
}}); 

$.each(message, function() {

    $('#tablesorter > tbody').append(
    '<tr><td>' + this.name
    + '</td><td>' + this.surname
    + '</td>' + '</tr>');
});

Note: myservice is a dwr service, don't know if it is related

I have error in chrome console

Uncaught Error: Syntax error, unrecognized expression: &gt;

&gt; means >

When I deleted the > the error disappears but it does not work as expected


Solution

  • Wherever you're outputting your code, it's getting transformed to automatically escape. Perhaps you have a templating language in between.

    You need to either store all of your javascript code in a separate file (the best solution), or find a way with your pages (JSP?) to disable output escaping.