I would like to save my json data object into my Postgresql using jQuery(ajax call on post request) and Java after clicking Submit button, Please help me to do this ? Thanks in advance.
html:
(function() {
var testValue;
testValue = {};
$('input[id=buttonId]').click(function() {
var name;
name = $(this).attr('name');
testValue[name] = $(this).val();
});
$('#submit').click(function() {
$('input[id=fileId]').each(function($i) {
var name;
name = $(this).attr('name');
testValue[name] = $(this).val();
});
console.log(JSON.stringify(testValue));//it gives the json data object, after clicking on Submit button`[ex: {"firstButton":"button1","secondButton":"button2","file":"test.txt"} ]`
});
})();
Postgresql table: create table savedata(id integer primary key, content json);
credentials:
db.default.driver=org.postgresql.Driver
db.default.url="jdbc:postgresql://localhost:5432/dbname"
db.default.user=test
db.default.password=test
html:
<input type='button' value='button1' class='button' id="buttonId" name='firstButton'/>
<input type='button' value='button2' class='button' id="buttonId" name='secondButton'/>
<input type='file' name='file' id="fileId" value='file upload'/>
<input type='submit' value='submit' id='submit'>