I'm trying to use the jQuery's getJSON function with Play framework. And I'm passing a query string with it. But it looks like it does not getting the value, only the key
Here's my jQuery function:-
<script type="text/javascript">
$(function() {
$("#button").click(function() {
$.getJSON(
'/getJsonResult',
{'foo':'bar'},
function(data) {
$.each(data, function(i, result) {
if(i != undefined) {
var result_html = '<ul><li>';
result_html += result + '<\/li><\/ul>';
$('#result_container').append(result_html);
}
});
}
);
});
});
</script>
Here's the action method:-
public static Result getJsonResult() {
Map queryParameters = request().queryString();
List data = Arrays.asList("result", "This is just a test");
if (queryParameters != null) {
System.out.println("QS Key ---> " + queryParameters.containsKey("foo"));
System.out.println("QS Value ---> " + queryParameters.containsValue("bar"));
}
return ok(Json.toJson(data));
}
The output:-
[info] play - Application started (Dev)
QS Key ---> true
QS Value ---> false