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

  • Home
  • SEARCH
  • 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 6541119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:03:54+00:00 2026-05-25T11:03:54+00:00

I have the following jQuery script… $(function() { $(‘.eventWrapper’).bind(‘click’, function(event) { var srvName =

  • 0

I have the following jQuery script…

$(function() {
    $('.eventWrapper').bind('click', function(event) {

        var srvName = $(this).data('service');
        var srvVal1 = $(this).data('serviceval');

        if (srvName == 'livestream')
        {
            var query = 'http://x'+srvVal1+'x.api.channel.livestream.com/2.0/livestatus.json?callback=?';
            $.getJSON(query, function(data)
            {
                if (data['channel']['isLive'])
                {
                    $(this).find('.eventTime').html('<b>Currently Live</b> ('+data['channel']['currentViewerCount']+' viewers)');
                }
            });
        }
    });
});

Its being run on the following code:

<div class="eventWrapper" data-service="livestream" data-serviceval="srklive">
    <div class="eventIcon"><a href=""><img src="image.php?u=3942"></a></div>
    <div class="eventName"><a href="">This is a test!</a></div>
    <div class="eventTime">09-02-2011 08:00 PM</div>
</div>

Its pretty self explanatory… it binds to the class .eventWrapper. When someone clicks anywhere in the div, it checks the data. If the data matches, it extracts a JSON query. This so far works perfectly fine.

The issue now is how to replace the text inside of the .eventTime class with what its supposed to. Obviously, I cant use $(this) because that relates to the existing getJSON function, not the bind function. How would I do this properly?

Also, how do I get the event to activate on page load, instead of on click?

  • 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-25T11:03:54+00:00Added an answer on May 25, 2026 at 11:03 am

    store this as a variable to use within $.getJSON’s callback so you’re referring to the correct context/this

    $(function() {
        $('.eventWrapper').bind('click', function(event) {
            var $this = $(this);
            var srvName = $(this).data('service');
            var srvVal1 = $(this).data('serviceval');
    
            if (srvName == 'livestream')
            {
                var query = 'http://x'+srvVal1+'x.api.channel.livestream.com/2.0/livestatus.json?callback=?';
                $.getJSON(query, function(data)
                {
                    if (data['channel']['isLive'])
                    {
                        $this.find('.eventTime').html('<b>Currently Live</b> ('+data['channel']['currentViewerCount']+' viewers)');
                    }
                });
            }
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following jQuery <script type=text/javascript> jQuery(function(){ jQuery('.link1').click(function(){ jQuery('.hide-div').hide(); jQuery('.toggle1').show(); jQuery('#arrow').css({top: '0px'}); });
I have the following Jquery script: $(document).ready(function () { // When the submit button
I have the following jQuery script: $(document).ready(function() { $.ajax({ url: 'temp.ajax.php', type: 'GET', success:
I have the following jquery-code: <script type=text/javascript> $(document).ready(function() { $ ('ul.image-list li:even').addClass ('even'); $
I have seen the following script from jQuery Validation Plugin. http://docs.jquery.com/Plugins/Validation/Methods/email email: function(value, element)
I have the following jQuery function embedded in an MVC Razor page: <script type=text/javascript>
In script#, I have the following: jQuery.Select(#someId).Trigger(item-added, new object[]{ball} ); This compiles into the
I have the following jQuery script that makes an orange transparent hover effect cover
I have the following jQuery script on my site to switch tabs without reloading
I have the following jqGrid script: jQuery(#editgrid).jqGrid({ url: editing.php?q=1, datatype: xml, // ... Where

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.