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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:57:38+00:00 2026-05-27T03:57:38+00:00

I have a page with multiple divs in it. I like to update the

  • 0

I have a page with multiple divs in it. I like to update the text inside these divs with the json response I get from the server.

The sample div looks like this

<div class="mprice" name="<?php echo $product['product_id']; ?>">
    <?php echo $product['price']; ?>
</div>

I have many of these divs on my page each one of them with a unique product_id as their name. I’m trying to update these prices every couple seconds.

So I have created an Ajax function that gets called on an interval to retrieve the new prices in json format.

json response that ajax is getting looks like this:

    {"products":[
    {"product_id":"43","price":"C$ 200.54"},
    {"product_id":"44","price":"C$ 928.08"},
    {"product_id":"46","price":"C$ 498.44"}

]}

Now I am trying to find a way to update all the prices in the div elements where their name is equal to the product_id with their corresponding price coming from json. I’m using jQuery. I’ve been on this for hours.

  • 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-27T03:57:39+00:00Added an answer on May 27, 2026 at 3:57 am

    Have your success handler do something like this:

    success: function( response ) {
        if( response && response.products ) {
            $.each( response.products,
                function( index, value ) {
                $( 'div[name="'+value.product_id+'"]' ).html( value.price );
                }
            );
        }
        else {
            console.log( "something went wrong :(", response );
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page with multiple divs, these are used to make tabs with
How can I update multiple parts from a page with Ajax? I have two
I have a overview page containing a list with some links from which multiple
I have multiple literals on a page. For example, <asp:Literal id=Label1 runat=server /> I
I have multiple divs in a page whose content gets loaded via ajax. I
I have a page with multiples divs like this <div class=bigbox> <a href=http://www.somestuff.com>some stuff</a>
I have multiple DIVs on my page and I'm having problems populating the correct
Okay, I have a page on a Drupal install that has multiple divs. I
I have multiple divs in my page as: <div imageId='image5' name='5' class='speechBubble'> <div imageId='image5'
I have a page that has multiple sliders (from http://www.switchonthecode.com/tutorials/using-jquery-slider-to-scroll-a-div ) and since each

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.