Good day!
I am trying to use jquery .post(). My problem is I want to get data from 2 different Action (java-struts2). Instead of getting the data of test2, it results to resending the page twice… so the data in my JSP also doubles.
My code is as follows:
$(function(){
$.post("test", function(data) {
$("#tester").html(data);
});
$.post("test2", function(data) {
$("#tester2").html(data);
});
});
HTML:
<div id="tester"></div>
<div id="tester2"></div>
How can i do the retrieving the data from 2 different actions(java) without the need of sending the data twice?
Thank you
When you send the JSON response from the server, group the data together something like this:
In your
$.postcallback, you will now have access to both piece of data in yourdatavar.