我是ajax新手
我有这个脚本,我想知道它的作用......大行我已经弄清楚了,但它仍然无法正常工作。
脚本如下:
function calcPrice(elem,id,pret,i){
$.ajax({
type: "POST",
url: "ajaxHandler.php",
data: "action=calcPrice&sign="+elem.className+"&id="+id+"&pret="+pret,
success: function(msg){
hcont = get_response_tag('tag1',msg);
hcont2 = get_response_tag('tag2',msg);
$(".price_val").html(hcont);
$(".nb_analize").html(hcont2);
if(elem.className=='plus'){ $("#p_row_"+i).removeClass("row_plus").addClass("row_minus"); elem.className = 'minus'; }
else{ $("#p_row_"+i).removeClass("row_minus").addClass("row_plus"); elem.className = 'plus'; }
}
});
}
我应该写一些东西ajaxHandler.php
让这个脚本工作吗?
html看起来像这样......(部分)
<div id="p_row_10" class="tableRow4 ">
<div class="tableRow4_leftBg float-left">10</div>
<div class="tableRow4_middleBg2 float-left">Ac. anti adenovirus</div>
<div class="tableRow4_middleBg3 float-left">73.00</div>
<div class="tableRow4_middleBg4 float-left">
<div class="plus" onclick="calcPrice(this,36,73.00,10)"></div>
</div>
</div>
<div id="p_row_11" class="tableRow4 ">
<div class="tableRow4_leftBg float-left">11</div>
<div class="tableRow4_middleBg2 float-left">Ac. anti ADN dublu catenar </div>
<div class="tableRow4_middleBg3 float-left">79.00</div>
<div class="tableRow4_middleBg4 float-left">
<div class="plus" onclick="calcPrice(this,37,79.00,11)"></div>
</div>
</div>
<div align="right">
<div class="cp_pret" >
<div class="t">TOTAL</div>
<div class="p"><span class="price_val">0</span> LEI</div>
</div>
</div>
</div>
谢谢你。