java - Multiple use of .post in jquery -


Good day!

I'm trying to use jquery .post (). My problem is that I want to get data from 2 different actions (Java-Stripe 2). Instead of receiving data of Test 2, this page sends again twice ... so data in my JSP is also doubled.

My code is as follows:

  $ (function () {$ .post ("test", function (data) {$ ("# tester"). (Data);}); $ .post ("test2", function (data) {$ ("# tester2") .html (data);});});   

HTML:

  & lt; Div id = "tester" & gt; & Lt; / Div & gt; & Lt; Div id = "tester2" & gt; & Lt; / Div & gt;   

How can I retrieve data from two different actions (java) without the need to send it twice?

Thanks

When you send a JSON response to the server, Send together with the group:

  <"tester2": [foo, bar], "tester2": "hello world"}   

Code> $ In the post callback, you now have access to both parts of the data in your data var

  console.log (data.tester) // = & gt; [Foo, bar] console.log (data.tester2) // = & gt; Hello world    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -