added jsonp to suggest servlet

This commit is contained in:
Michael Peter Christen 2015-07-16 23:42:41 +02:00
parent 0e87a99ab8
commit 785781253e
2 changed files with 11 additions and 1 deletions

View File

@ -102,6 +102,16 @@ public class suggest {
prop.putHTML("query", originalquerystring);
}
// check for JSONP
if ( post.containsKey("callback") ) {
final String jsonp = post.get("callback") + "([";
prop.put("jsonp-start", jsonp);
prop.put("jsonp-end", "])");
} else {
prop.put("jsonp-start", "");
prop.put("jsonp-end", "");
}
// Adding CORS Access header for xml output
if (xml) {
final ResponseHeader outgoingHeader = new ResponseHeader(200);

View File

@ -1 +1 @@
["#[query]#",[#{suggestions}#"#[text]#"#(eol)#,::#(/eol)##{/suggestions}#]]
#[jsonp-start]#["#[query]#",[#{suggestions}#"#[text]#"#(eol)#,::#(/eol)##{/suggestions}#]]#[jsonp-end]#