- 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
This commit is contained in:
apfelmaennchen 2009-03-07 10:18:47 +00:00
parent d84264946b
commit 4f3bdc64b5
2 changed files with 14 additions and 2 deletions

View File

@ -126,7 +126,17 @@ public class yacysearch {
return prop; 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 // collect search attributes
boolean newsearch = post.hasValue("query") && post.hasValue("former") && !post.get("query","").equalsIgnoreCase(post.get("former","")); //new search term boolean newsearch = post.hasValue("query") && post.hasValue("former") && !post.get("query","").equalsIgnoreCase(post.get("former","")); //new search term

View File

@ -1,3 +1,4 @@
#[jsonp-start]#
{ {
"xmlns$yacy": "http://www.yacy.net/", "xmlns$yacy": "http://www.yacy.net/",
"xmlns$os": "http://a9.com/-/spec/opensearch/1.1/", "xmlns$os": "http://a9.com/-/spec/opensearch/1.1/",
@ -22,4 +23,5 @@
], ],
<!--#include virtual="yacysearchtrailer.json?eventID=#[eventID]#" --> <!--#include virtual="yacysearchtrailer.json?eventID=#[eventID]#" -->
}] }]
} }
#[jsonp-end]#