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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:32:09+00:00 2026-06-12T08:32:09+00:00

Heres my client-side code <!DOCTYPE html> <html lang=en> <head> <meta charset=utf-8> <title>Alerter</title> </head> <body>

  • 0

Heres my client-side code

<!DOCTYPE html>
 <html lang="en">
 <head>
   <meta charset="utf-8">
   <title>Alerter</title>
 </head>
 <body>
   <script src="jquery.min.js"></script>
   <script src="http://www.example.com:8001/socket.io/socket.io.js"></script>
   <script>
     $(document).ready(function(){

       var socket = io.connect('http://www.example.com:8001');
       socket.on('message', function (data) { do_message(data) });
     });

   function do_message(data){
     var $obj=$(jQuery.parseJSON(data));
     //now what goes in here? 
   };
</script>
</body>
</html>

And the javascript object I receive looks like

{
    "root": {
        "status": [
            "OK"
        ],
        "alert": [
            {
                "$": { "src": "web" },
                "time": [ "1349316382" ],
                "id": [ "user1" ]
            },
            {
                "$": { "src": "web" },
                "time": [ "1349316391" ],
                "id": [ "user2" ]
            },
        ]
    }
}

And what I want to do is iterate over each of the “alert” entries and take appropriate action (the actual schema is a bit more complicated than I’ve shown above)

Are jQuery selectors the right tool for this task or should I got back to native javascript (ie getElementsByTagName or similar). All the jQuery docs are based around selecting valid html tags from the DOM, I cant figure out how to select arbitary tags from the received message.

  • 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-12T08:32:11+00:00Added an answer on June 12, 2026 at 8:32 am

    You can iterate over the data using $.forEach:

    var obj = jQuery.parseJSON(data);
    
    $.each(obj['root']['alert'], function(index, value) {
        console.log(value.id);
    });
    

    Or you can just use regular JS:

    var obj = jQuery.parseJSON(data);
    var alerts = obj['root']['alert'];
    
    for (var key in alerts) {
        var value = alerts[key];
    
        console.log(value.id);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem. Client side code <html> <body onload=fun()> <script src=C:\cygwin\usr\local\lib\node\.npm\socket.io\0.6.16\package\support\socket.io-client\socket.io.js></script> <script> function
Here's my client-side jQuery code: $.ajaxSetup ({ contentType: application/json, datatype: 'json' }); $.ajax({ type:
Here is client Side code: jQuery(document).ready(function(){ jQuery(#list).jqGrid({ url:'example.php', datatype: 'xml', mtype: 'GET', colNames:['Inv No','Date',
I'm having to modify some client side code because the comms protocol wasn't defined
I am sending ajax request to the server as : Client Side Code :
Here's my client-side code: $(#grid).jqGrid({ url: /Entry/EntryListingByBreed/, datatype: json, mtype: POST, postData: { showId:
Some RAD tools like openobject use rich web clients. I.e. their client side code
I want to set the Image URL of Image control using client side code
Let's say I'm generating markup through server-side code. I'm generating a bunch of HTML
hello i am abit new in client side programming and html, i am trying

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.