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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:24:04+00:00 2026-06-14T06:24:04+00:00

In one of my applications, i am fetching json data from php and rendering

  • 0

In one of my applications, i am fetching json data from php and rendering the html from that using ajax/jquery

I render listing of products with some star rating plugin. The problem is that the plugin works fine when rendered initially with page refresh. When i apply a price filter (this actually fetches json and renders with ajax), the plugin stops working as it is unable to bind to dynamically inserted listing with ajax.

plugin initialization code goes like this

jQuery.noConflict ();
var jq = jQuery;
jq(document).ready(function(e) {
    jq('.auto-submit-starc').rating({
        callback: function(value, link){
            product_id=this.name;
            rating=value;
            jq.post('<?PHP echo base_url();?>index.php/showproducts/awardRating',{id:product_id,rating:rating},function(data){});
        }
    });   
});

And this is what fetches the json:

    // Price range
('select#valueA, select#valueB').selectToUISlider({
    labels:8,
    sliderOptions: {
        stop: function(e,ui) {
            jq(".list-items").css('width','100%').css('height','700px').css('background-color','#EFEFEF').css('opacity','0.5').css('text-align','center').html("<img src='http://tharhandloom.in/images/preloader.gif'/>");

            var startk = jq('#valueA').val();
            var endk = jq('#valueB').val();

            var start=startk.replace('k', '000')
            var end=endk.replace('k', '000')

            var catid="<?PHP echo @$category['id'];?>";   
           jq.post('<?PHP echo base_url()?>index.php/showproducts/ajaxFilterProducts',
                   {start:start,end:end,catid:catid},
                   function(data){          
                       var json=jQuery.parseJSON(data);                
                       var html="";
                       jq(json).each(function(index,element){
                           if(element.name.length>21)
                               productName=element.name.substring(0,21)+"...";
                           else
                               productName=element.name;
                           html+='<div class="single-item"><span class="title"><a href="#">'+productName+'</a></span><input class="auto-submit-starc" type="radio" name="'+element.id+'" value="1"/><input class="auto-submit-starc" type="radio" name="'+element.id+'" value="2" id="rate_second"><input class="auto-submit-starc" type="radio" name="'+element.id+'" value="3" id="rate_third" /><input class="auto-submit-starc" type="radio" name="'+element.id+'" value="4" id="rate_fourth" /><input class="auto-submit-starc" type="radio" name="'+element.id+'" value="5" id="rate_fifth"/><span class="price">Rs '+element.price+'</span><img src="http://tharhandloom.in/product_images/thumbnails/'+element.product_image+'" alt="Item"/><div style="text-align:center"><a href="<?PHP echo base_url();?>cart/'+element.id+'" class="general-button float-left"><span class="button">Add to cart</span></a></div><br class="clear"/></div>';     
                        });
                        jq(".list-items").css('background-color','').css('opacity','').css('text-align','').css('width','').css('height','').html(html);

                    });

             }
         }          
});

As can be seen that in the html i am inserting radio buttons. The plugin actually captures the classes of radio buttons and applies the functionalities to them. But when new radio buttons are inserted via ajax, the plugin is unable to capture there classes.

I guess it can be accomplished with .live method but don’t know how to use it.

  • 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-14T06:24:06+00:00Added an answer on June 14, 2026 at 6:24 am

    You should simply run jq('.auto-submit-starc').rating(...); after this line:

    jq(".list-items").css('background-color','').css('opacity','').css('text-align','').css('width','').css('height','').html(html);
    

    .live is to bind events and it will not help you with applying plugin because it simply catches all events on document and looking for events related to event.target selector or something like that. It does not check if something is changed on a page. And besides, .live is deprecated in newer versions of jQuery. You should use .on instead.

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

Sidebar

Related Questions

I'm having a problem fetching results from a Core Data store using predicates. What
I have a UIViewController and in that controller, i am fetching an image from
I am working on one application where i am fetching some data in uitableview
I am fetching records from one table with count of one field with other
i created an iPad application, in which i am fetching data from URL, when
I am creating an iPad App that displays data I got from an API
I am currently working on an application which requires fetching of data from the
I have developed a small application using Perl/Tk. The application will fetch data from
Our server (several Java applications on Debian) handles incoming data (GNSS observations) that should
I'am developing an application which is totally based on fetching data from web services.

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.