Solved

How to read JSON response in JSP

Posted on 2015-01-18
2
306 Views
Last Modified: 2015-01-19
Hi guys,

In JSP page, I am calling dojo/Ajax as below:

                 var number1=43;
            params.input1 = number1;
            var xhrArgs1 = {
              url : 'AJAXComand',
                  handleAs : 'text',
                content : params,
                preventCache:false,
                load:function(data){
                    //alert('success!');
                    handleResponse(data);
                 },
                 error: function(error){
                   alert(error);
                  },
                 timeout:100000
            };
                dojo.xhrPost(xhrArgs1);
      
      }
      function handleResponse(data){
            data = data.replace("/*", "");
                  data = data.replace("*/", "");  
                  var obj = eval('(' + data + ')');
          console.debug(obj);
          }

----------
If I see in browser debugger: I see this

(
 {
  input1:["43"],
  input2:["21"],
  message1:"Message 1 Data",
  message2:"This is another test data."
 }
)
@ http://localhost/app_home/
-----------
How can I get value of message1 and message2 and set to div of id "test1"

something like this???
document.getElementById("test1").innerHTML = data.message1;
0
Comment
Question by:student237
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 14

Accepted Solution

by:
quizwedge earned 500 total points
ID: 40557018
Given that you already have obj, if I'm reading things correctly, try

document.getElementById("test1").innerHTML = obj.message1

Open in new window

0
 

Author Closing Comment

by:student237
ID: 40557891
Thank you for the response.
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
object method as an event handler 8 77
Javascript Error 10 24
Jquery syntax 12 30
Drag & Drop Error 5 33
New Relic: Our company recently started researching several products to figure out what were the best ways for us to increase our web page speed and to quickly identify performance problems that we may be having. One of the products we evaluated wa…
Foolproof security solutions has become one of the key necessities of every e-commerce or Internet banking website. If you too own an online shopping site then its vital for you to equip your web portal with customer security features that can allow…
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question