Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

- added ?callback= parameter for JsonP support - this is needed for json ajax cross domain calls - see: http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/

apfelmaennchen4f3bdc64b540
diff --git a/htroot/yacysearch.java b/htroot/yacysearch.java
index a0c4d3eb4..260e6bd77 100644
--- a/htroot/yacysearch.java
+++ b/htroot/yacysearch.java
@@ -126,7 +126,17 @@ public class yacysearch {
return prop;
}
-
+
+ // 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", "");
+ }
+
// collect search attributes
boolean newsearch = post.hasValue("query") && post.hasValue("former") && !post.get("query","").equalsIgnoreCase(post.get("former","")); //new search term
diff --git a/htroot/yacysearch.json b/htroot/yacysearch.json
index 38105d95d..b430eb077 100644
--- a/htroot/yacysearch.json
+++ b/htroot/yacysearch.json
@@ -1,3 +1,4 @@
+#[jsonp-start]#
{
"xmlns$yacy": "http://www.yacy.net/",
"xmlns$os": "http://a9.com/-/spec/opensearch/1.1/",
@@ -22,4 +23,5 @@
],
<!--#include virtual="yacysearchtrailer.json?eventID=#[eventID]#" -->
}]
-}
\ No newline at end of file
+}
+#[jsonp-end]#
\ No newline at end of file