Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to render jquery ajax response
    primarykey
    data
    text
    <p>I'm quite new to jquery ajax and I'm trying to figure out how can I render the response data what I get back from php as json to update a specified div. So practically I'm having the following issue.</p> <p>The JavaScript:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function() { $(".ajax_call").change(function() { var domain = document.domain; var count = $('.ajax_call :selected').val(); var $parent = $(this).closest(".product_box"); var modul_title = $("h4", $parent).text(); $.ajax({ url:'index/ajax', data:{mod_title:modul_title, domain:domain, count:count}, cache:'false', datatype:'json', success: function(response) { if (response.status = modul_title) { $parent.fadeOut(); $parents.(response).fadeIn(); } else { alert("Oops, script is a no go"); } } }); }); }); </code></pre> <p>And the HTML:</p> <pre><code>&lt;div class="product_box"&gt; &lt;h4&gt;&lt;!-- php code generating --&gt; header&lt;/h1&gt; &lt;div class="product"&gt; &lt;div class="thumbnail-item"&gt; &lt;a href=""&gt;&lt;/a&gt; &lt;!-- and couple of other divs what are rendering my output in my mvc view --&gt; &lt;div class="ajax_bar"&gt; &lt;!-- and here comes the dropdown what is triggering an ajax call --&gt; &lt;select class="ajax_call" size="1" name="blala"&gt; &lt;option value='50'&gt;add more 50&lt;/option&gt; &lt;option value='100'&gt;add more 100&lt;/option&gt; &lt;option value='150'&gt;add more 150&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>What I want is to update the number of presented items with an ajax call. What is not clear to me how to render the response. Do I have to form the raw data again I mean as my html-php code looks or it can be done in another way?</p>
    singulars
    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.
 

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