Skip to content

Commit

Permalink
- added ?callback= parameter for JsonP support
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
apfelmaennchen committed Mar 7, 2009
1 parent d842649 commit 4f3bdc6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 11 additions & 1 deletion htroot/yacysearch.java
Expand Up @@ -126,7 +126,17 @@ public static serverObjects respond(final httpRequestHeader header, final server

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

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

0 comments on commit 4f3bdc6

Please sign in to comment.