From 4f3bdc64b5409e0951261398e57cc7c333d13f9d Mon Sep 17 00:00:00 2001 From: apfelmaennchen Date: Sat, 7 Mar 2009 10:18:47 +0000 Subject: [PATCH] - 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/ git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5674 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/yacysearch.java | 12 +++++++++++- htroot/yacysearch.json | 4 +++- 2 files changed, 14 insertions(+), 2 deletions(-) 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 @@ ], }] -} \ No newline at end of file +} +#[jsonp-end]# \ No newline at end of file