From 785781253e3265a3515750cc98469afc04ec2365 Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Thu, 16 Jul 2015 23:42:41 +0200 Subject: [PATCH] added jsonp to suggest servlet --- htroot/suggest.java | 10 ++++++++++ htroot/suggest.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/htroot/suggest.java b/htroot/suggest.java index 441505299..552b0e601 100644 --- a/htroot/suggest.java +++ b/htroot/suggest.java @@ -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); diff --git a/htroot/suggest.json b/htroot/suggest.json index fab9e4743..222c110c3 100644 --- a/htroot/suggest.json +++ b/htroot/suggest.json @@ -1 +1 @@ -["#[query]#",[#{suggestions}#"#[text]#"#(eol)#,::#(/eol)##{/suggestions}#]] +#[jsonp-start]#["#[query]#",[#{suggestions}#"#[text]#"#(eol)#,::#(/eol)##{/suggestions}#]]#[jsonp-end]# \ No newline at end of file