Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have to write a ajax callback function, in which I have json object , When I test with alert it shows `[object Object],[object Object],[object Object]`. Here each object contain 6 variables. I have to display each obj values in each row . How can I do this.

Here is my code,

JavaScript
if (xmlHttpReqRM.readyState == 4) {
      if (xmlHttpReqRM.status == 200) {
      var responceeString = xmlHttpReqRM.responseText;
      var jsonobj= JSON.parse(xmlHttpReqRM.responseText);
      alert(jsonobj);



my jsp table is like this,

<pre lang="HTML">

<div id="tab1">  
    <table id="flexme1">
    <thead>
                <tr>
                    <td width="140"><h3>VehicleNo</h3></td>
                    <td width="140"><h3>Latitude</h3></td>
                    <td width="140"><h3>Longitude</h3></td>
                    <td width="140"><h3>Status</h3></td>
                    <td width="140"><h3>RDate</h3></td>
                    <td width="140"><h3>RTime</h3></td>
                 </tr>
                 </thead>
                  <tbody>
               
                </tbody>
     </table>
     </div>



How can I do this can any one help me.
Posted
Comments
vangapally Naveen Kumar 22-Aug-14 2:38am    
use anonymous class and assign result set to the that then using for loop u can assign the values .at code behind(cs page).
Sergey Alexandrovich Kryukov 22-Aug-14 2:43am    
What "cs"? This is JSP. But the idea would be basically correct, only, in many cases, named type should be used for parsing JSON onto a .NET object. With JSP, it will be pretty similar thing. The problem is: the question is not quite clear, please see my comment below...
—SA
Raghavendra M 22-Aug-14 2:46am    
can u please show me with small peace of code
Sergey Alexandrovich Kryukov 22-Aug-14 2:44am    
What code? Who are you asking? :-)
Use "Reply", strictly of the post you are replying to, otherwise the participated members won't get adequate notifications on your comments.
—SA
Sergey Alexandrovich Kryukov 22-Aug-14 2:41am    
How is that related to JSP? Do you need to parse JSON on the server side? If not, why using Ajax? If yes, where is your Ajax call?
The problem looks pretty simple, only you need to understand clearly what is processed where. From you code samples, this is not clear.
—SA

1 solution

Below code may help you ,
It will help you to go through one by one data.
.each() in jquery
"Javascript"
$.each(jsonobj, function(){
      //Bind your table here.
});
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900