Dumb qestion: how get json to read html?
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 <strong>Osca</strong>r Wilde
Why? I think is a very stupid error..
Edit: Nothing wo开发者_C百科rked 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
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
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.
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
精彩评论