I wanted to use data from javascript/jquery in a java class.
I get data from another server as a postresult to my servlet. I want to use this data. This data is a JSON String. The Response looks like this:
[{"id":"1","bool_m":"0","name":"Test 1"},{"id":"2","bool_m":"1","name":"Test 2"},{"id":"3","bool_m":"0","name":"Test 3"}]
How can i archive this? If i create a new java-object and pass "data" into the constructor it wont know "data".
this is what i got(this code runs as a .jsp on a liferay-server (which uses tomcat)):
<script type="text/javascript">
function getScenarioList() {
$.post("url",
{
action : "get_scenario_list"
})
.done(function(data) {
alert("Data Loaded: "+ data);
<%
Testclass one = new Testclass(data);
%>
});
}
</script>