views:

59

answers:

3

I'm very new to Json and JQuery. I got autocomplete Jquery UI plugin that return a Json Object. Ex it return ["Tim ferriss","stack overflow","<strong>Oscar</strong> Wilde"] In the browser the strong tag is seen as &lt;strong&gt;Osca&lt;/strong&gt;r Wilde Why? I think is a very stupid error..

Edit: Nothing worked so far.This is the code

function highlight(s, t) {
var matcher = new RegExp("("+$.ui.autocomplete.escapeRegex(t)+")", "ig" );
return s.replace(matcher, "<strong>$1</strong>");
}

I think that json object is converted in a javascript object. I have the same issue anyway

+3  A: 

You would do well to figure out why the HTML is being escaped. There should be some good reason (often security related).

Have a look here http://erlend.oftedal.no/blog/?blogid=14

Eamorr
A: 

make your query as html, by default it is assumed json. So string sent by the server translates safe values by getter.

In jquery post page there is an example like:

 $.post("test.php", { name: "John", time: "2pm" },
  function(data){
    process(data);
  }, "xml");

you can try replacing html with xml

nerkn
+2  A: 

The items in the JSON object are text values only, they are not pure HTML items, so you cannot style them this way.

Have a look here: http://docs.jquery.com/UI/Autocomplete

You can style it with the jQuery UI themes.

VasilP