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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:04:46+00:00 2026-06-12T23:04:46+00:00

I have such jquery code: jQuery(function($) { $(document).ready(function () { $(‘.lol’).each(function(index) { console.log(#+$(this).attr(id)); $.ajax({

  • 0

I have such jquery code:

jQuery(function($) {
  $(document).ready(function () {
    $('.lol').each(function(index) {
      console.log("#"+$(this).attr("id"));
      $.ajax({ 
        url: "/articles/get_prices/nr="+$(this).attr("nr")+"&br="+$(this).attr("br")+"&type="+$(this).attr("type"), 
        type: "GET", 
        data: {},
        success: function(text)
        {
          $("#"+$(this).attr("id")).html(text);
        },
        error: function(){
          alert('Ошибка javascript');
        },
        dataType : "html"
      });
    });
  });
});

and such haml code

.box{:id => art.ART_ARTICLE_NR.gsub(/[^0-9A-Za-z]/, '')}

method

def get_prices()
    nr = params[:nr]
    br = params[:br]
    type = params[:type]
    @pr = find_price(nr, br, type)
    respond_to do |format|
      format.html { render :partial=>"search_trees/price" }
    end
  end

i need to set this div jquery value, but it is all dynamic, so after page loads, it go to db, and via id (which is another for each box) set it a value.

  • 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-12T23:04:47+00:00Added an answer on June 12, 2026 at 11:04 pm

    try this, your js file:

    $(document).ready(function(){
      $('.lol').each(function() {
        url = "/articles/get_prices/nr="+$(this).attr("nr")+"&br="+$(this).attr("br")+"&type="+$(this).attr("type")+'&id='+$(this).attr('id');
        $.get(url,function(){},'script');
      })
    })
    

    (you do an ajax request with script datatype, so the response gets executed and you don’t need to handle that by yourself)

    your controller:

    def get_prices()
      nr = params[:nr]
      br = params[:br]
      type = params[:type]
      @pr = find_price(nr, br, type)
      @id = params[:id]
      respond_to do |format|
        format.js { render :partial=>"search_trees/price" }
      end
    end
    

    (add the instance variable @id and render a js view since the ajax request is ‘script’ type)

    your view (search_trees/price.js.erb, this is important that you submit a js file)

    $("#<%= @id -%>").html(<%= javascript_escape(render(:partial => "search_trees/price.html")) -%>);
    

    (render the html view and set the html of the div)

    you might want to add some checks to do the alert if something goes wrong (like… you can’t fine the @pr object), so you cover both cases:

    in your view:

    <%- if @pr.nil? -%>
      alert('Ошибка javascript');
    <%- else -%>
      $("#<%= @id -%>").html(<%= escape_javascript(render(:partial => "search_trees/price.html")) -%>);
    <%- end -%>
    
    • 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 code: $(document).ready(function() { $(#build_table, a.coursename, .Start Date, .Book Title,
I have some nice dialogues defined as such in jQuery: <script type=text/javascript> $(document).ready(function() {
In Jquery theres a function $(document).ready(function (){..} Is there such a thing in Sencha
I have a few lines of jQuery in my web application. This code is
I have such code: <script src=http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js type=text/javascript></script> <script type=text/javascript> $(document).ready(function(){ var my_id = 'iddate';
I have this jQuery code that queries an API on a keyup event (via
I have such problem: I'm using rails, devise gem and jQuery validation plugin. I
have such zend query: $select = $this->_table ->select() ->where('title LIKE ?', '%'.$searchWord.'%') ->where('description LIKE
i have such code (copy paste from wiki). Its multiplication of those big numbers
i have such function to solve some logic riddle iloczyny is list with such

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.