私はjquery ajaxを初めて使用し、phpから返された応答データをjsonとしてレンダリングして、指定されたdivを更新する方法を理解しようとしています。したがって、実際には次の問題があります。
JavaScript:
<script type="text/javascript">
$(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");
}
}
});
});
});
そしてHTML:
<div class="product_box">
<h4><!-- php code generating --> header</h1>
<div class="product">
<div class="thumbnail-item">
<a href=""></a>
<!-- and couple of other divs what are rendering my output in my mvc view -->
<div class="ajax_bar">
<!-- and here comes the dropdown what is triggering an ajax call -->
<select class="ajax_call" size="1" name="blala">
<option value='50'>add more 50</option>
<option value='100'>add more 100</option>
<option value='150'>add more 150</option>
</select>
</div>
</div>
</div>
</div>
私が欲しいのは、提示されたアイテムの数をajax呼び出しで更新することです。応答をレンダリングする方法がわかりません。私のhtml-phpコードが見えるように、生データを再度形成する必要がありますか、それとも別の方法で行うことができますか?