我不会写ajax来POST一个东西给数据库来做删除 收藏的功能。。。求指点啊
模板代码:
<div style="height:45px;"></div>
{% if merchant_list %}
{% for merchant in merchant_list %}
<div class="collect">
<span class="collect-left"><a href=""><img src="/static/images/home10.png"></a></span>
<span class="collect-right">
<h4>{{ merchant.name }}</h4>
<p>{{ merchant.address }}</p>
<p>配送时间:<a class="colorred">{{ merchant.service_start_time|date:"H: i" }}-{{ merchant.service_end_time|date:"H: i" }}</a></p>
<p class="coloryellow fontsize12">{{ merchant.free_start_price }}元起送</p>
<button class="delete" del_id="{{ merchant.id}}">删除此收藏</button>
jquery代码:
<script type="text/javascript" src="/static/js/jquery.js"></script>
<script>
$(document).ready(function(){
$('.delete').click(function(){
if(confirm("是否删除此收藏"))
$(this).parents(".collect").remove();
var del_id=$(this).val()
$.post('/wechat/my/del_favorite',{'del':del_id })
});
});