I'm new to play and I am trying to post form data to my Play Action using JQuery. However, I'm getting "expected json" response from Action. I check the HTTP Headers to ensure that the data is being sent and it is so, where am I going wrong and how can I fix it.(Is there a better approach to this)
Script:
$(document).ready (function (){ $("form").submit (function (e) { e.preventDefault(); $.post("/save",$(this).serialize(),function (data){ alert(data); }); }); }); Action
public static Result save() { JsonNode json = request().body().asJson(); if (json == null) return ok("expected json"); else { String value = json.findPath("video").getTextValue(); if (value == null) return ok("did not find"); else return ok(value) ; } } routes
POST /save controllers.Application.save()