Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- POST /json @controllers.Application.saveJsonData
- def saveJsonData = Action { request =>
- val body: AnyContext = request.body
- val jsonBody: Option[JsValue] = body.asJson
- jsonBody.map {json =>
- dao.persist(json) // stores in database, not found: dao
- Ok("Saved")
- }.getOrElse {
- BadRequest("Expecting text/json request.body")
- }
- }
- db.default.driver=org.postgresql.Driver
- db.default.url="jdbc:postgresql://localhost:5432/database"
- db.default.user=test
- db.default.password=1234
- val appDependencies = Seq(
- "org.postgresql" % "postgresql" % "9.4-1200-jdbc41",
- "postgresql" % "postgresql" % "9.1-901.jdbc4"
- )
- (function() {
- var buttonValue = {};
- $("#submit").click(function() {
- $("input[type=button], input[type=file]").each(function($i) {
- var name = $(this).attr('name')
- buttonValue[name] = $(this).val();
- });
- console.log(JSON.stringify(buttonValue));//json object: [ex: {"firstButton":"button1","secondButton":"button2","file":"test.txt"} ], this json object should store in PostgreSQL database table as it is after clicking of Submit button.
- });
- }())
- <input type='submit' value='Submit Json' id='submitJson'>
- create table saveJsonData(id integer primary key, content json);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement