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 7500555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:13:34+00:00 2026-05-29T20:13:34+00:00

Hi how to get json array elements in different ids in response? //server side

  • 0

Hi how to get json array elements in different ids in response?

//server side jsp

 <%@page import="net.sf.json.JSONObject"%>
<%@page import="net.sf.json.JSONArray"%>
<%
  JSONArray arrayObj=new JSONArray();               
 JSONObject obj=new JSONObject();
 obj.put("name","data");// how can i display string "name" in secondcombobox id?
 obj.put("roll_no","data"); how can i display string "roll_no" in thirdcombobox id?
 out.println(obj.toString());
%>

client side jsp where retrieving json array elements in javascript

 $("#firstcombo").change(function() {
 $.get('comboboxpage.jsp', { combo1Val : $(this).val() }, function(responseData) {
 $("#secondcomboboxid").replaceWith(data.name);// here i want to display name, how can i do it?
 $("#thirdcomboboxid").replaceWith(data.roll_no);// here i want to display roll no, how can i do it?
});
});

<input type="text" id="secondcomboboxid" name="secondcomboboxid"/>// how can i show name here?
<input type="text" id="thirdcomboboxid" name="thirdcomboboxid"/> how can i show roll_no here?

How can i display name in secondcomboboxid and roll no in thirdcomboboxid? I googled a lot but could not find any solution, Any ideas please

  • 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-05-29T20:13:35+00:00Added an answer on May 29, 2026 at 8:13 pm

    try this

    <%
              JSONObject arrayObj= new JSONObject();
    
               arrayObj.put("name","john");
               arrayObj.put("roll no","007");
    
    
              response.setContentType("application/json");
              response.getWriter().write(arrayObj.toString());
    
    %>
    

    client side

    $.ajax({
    url:'comboboxpage.jsp',
    dataType:'json',
    type:'GET',
    success:function(data){
    console.log(data);
    },
    error:function(jxhr){
    console.log(jxhr.responseText);
    }
    
    }); 
    

    here is a helpful link

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I get JSON array from Ext.data.Store outside the function? The code: var
Noob question. Setting array elements throws an error. I get this error when I
How to import json file in action script and then get random element from
I have a jQuery DataTable configured for server-side processing against an ASP.NET MVC server.
I want to get the value of json array using .each here's where I
I have a JSON array coming in from the server with an array of
I'm currently using $.getJSON to pass an array of ids. It basically constructs a
What C-sharp type can I serialize to get JSON object with format name:[[1,2,3],[1,2,3],[1,2,3]] If
Trying to get a JSON output to work with jqGrid 'userdata' option. The example
While trying to GET a JSON, my callback function is NOT firing. $.ajax({ type:GET,

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.