Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8010793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:50:45+00:00 2026-06-04T18:50:45+00:00

Servlet String getCodeList = (new JSONArray(rmsCodeList)).toString(); response.setContentType(application/json); response.setCharacterEncoding(UTF-8); response.getWriter().write(getCodeList); Jquery $(document).ready(function() { var getdata;

  • 0

Servlet

 String getCodeList = (new JSONArray(rmsCodeList)).toString();
 response.setContentType("application/json");
 response.setCharacterEncoding("UTF-8");
 response.getWriter().write(getCodeList);

Jquery

$(document).ready(function() {
var getdata;
$.post("GetItemCode", function(data) {
    getdata=data;

});
}); 

working fine, I get the complete array on getdata

Write Two

 String getCodeList = (new JSONArray(rmsCodeList)).toString();
 response.setContentType("application/json");
 response.setCharacterEncoding("UTF-8");
 response.getWriter().write(getCodeList);


 String getNameList = (new JSONArray(rmsNameList)).toString();
 response.setContentType("application/json");
 response.setCharacterEncoding("UTF-8");
 response.getWriter().write(getNameList);

How can I get two array on different variable

$(document).ready(function() {
var getdata1;
var getdata2;
$.post("GetItemCode", function(data) {
    getdata1=?;
    getdata2=?;

});
}); 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T18:50:46+00:00Added an answer on June 4, 2026 at 6:50 pm

    Put the two arrays in a JSONObject and retrieve it in Javascript

    response.setContentType("application/json");
    response.setCharacterEncoding("UTF-8");
    response.getWriter().write(
        new JSONObject()
            .put("codeList", new JSONArray(rmsCodeList))
            .put("nameList", new JSONArray(rmsNameList)).toString()
    );
    

    Then in Javascript you retrieve it as a property of the returned object.

    $(document).ready(function() {
        var getdata1;
        var getdata2;
        $.post("GetItemCode", function(data) {
            getdata1 = data.codeList;
            getdata2 = data.nameList;
        });
    }); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I will be passing a json string to a servlet via an ajax request
I am returning a JSON object (as a String) through a servlet. The JSON
I'm trying to POSt a UTF-8 string to my servlet (hosted in TomCat) but
My servlet on receiving first request from client: //1. ObjectInputStream in=new ObjectInputStream(req.getInputStream()); String r=(String)
I'm using ajax to make a request on a servletand receive json String servlet
I made a servlet which creates a Map Object: Map<String, Integer> data = new
I get a JSON String from a Servlet und want to parse this string
I have created a servlet that passes a string variable strname to a JSP
I have a xml file content as string in my servlet, I need to
I added Comet servlet into Spring web application. This servlet does not differ from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.