Note that there are some explanatory texts on larger screens.

plurals
  1. POcall javascript function in every div in html
    primarykey
    data
    text
    <p>Hi I have a javascript function and I want it to call when the c_id loops each. but I don't have an idea about it.</p> <p>here is my function.</p> <pre><code> function getCLowestPrice(c_id){ $.ajax({ type: "POST", url: 'http://sample.com/api/store_lowest_price/', dataType: "xml", cache: false, data: {'id' : c_id}, success: function(resp){ // we have the response console.log(resp); $(resp).find("response").each(function() { var c_name = $(this).find("c_name").text(); var c_currency = $(this).find("currency").text(); var c_min_price = $(this).find("price_min").text(); var formated_price = addCommas(parseFloat(c_min_price).toFixed(2)); $('.cinformation').html("&lt;p&gt;Lowest Price : " + c_currency + " " + formated_price + "&lt;/p&gt;"); }); }, }); } </code></pre> <p>and I want it to call when the div loaded. but it loops all the clients and also their c_id.</p> <pre><code>&lt;div&gt; Client : &lt;?php echo get_post_meta($post-&gt;ID, 'wpcf-c', true); ?&gt; &lt;div class="cinformation"&gt; C ID = &lt;?php echo get_post_meta($post-&gt;ID, 'wpcf-c-id', true); ?&gt; .... &lt;/div&gt; ... &lt;/div&gt; </code></pre> <p>so it will be this when it loops.</p> <pre><code>&lt;div&gt; Client : Hello &lt;div class="cinformation"&gt; C ID = 1 .... &lt;/div&gt; ... &lt;/div&gt; .... &lt;div&gt; Client : World &lt;div class="cinformation"&gt; C ID = 2 .... &lt;/div&gt; ... &lt;/div&gt; .... .... ... </code></pre> <p>but i don't have any idea on how can I add the <code>getCLowestPrice(c_id)</code> in the <code>cinformation div</code>.</p> <p>I try to use the <code>onload</code> but it can't be used in div.</p> <p>does anyone have an idea about my case?</p> <p>thanks in advance ...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload