其他分享
首页 > 其他分享> > HTML修改弹出框

HTML修改弹出框

作者:互联网

            <div class="form-group">
                <label class="control-label">直播清晰度:</label>
                <p class="form-control-static">{{ shop.get_clarity_type_display }}&nbsp;
                    <a href="javascript:;" data-toggle="modal" data-target="#liveModal">修改</a>
                </p>
            </div>
<div class="modal fade" id="liveModal" tabindex="-1" role="dialog" aria-labelledby="liveModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="liveModalLabel">修改直播清晰度</h4>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal" method="post" onsubmit="return false;" id="live_clarity_form">
                        {% csrf_token %}
                        <input type="hidden" name="shop_id" value="{{ shop.id }}">
                        <div class="form-group">
                            <label for="id_address" class="col-sm-2 control-label"><span
                                    class="required">*</span>直播清晰度</label>
                             <select class="form-control" name="live_clarity" id="live_clarity_id">
                                <option value="SD" {% if shop.clarity_type == 'SD' %}selected{% endif %}>标清</option>
                                <option value="HD" {% if shop.clarity_type == 'HD' %}selected{% endif %}>高清</option>
                                <option value="FHD" {% if shop.clarity_type == 'FHD' %}selected{% endif %}>超清</option>
                            </select>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary" onclick="saveLiveClarity()">保存</button>
                </div>
            </div>
        </div>
    </div>
function saveLiveClarity() {
            $.ajax({
                url: "/super_manage/save_shop_claritytype/",
                data: $("#live_clarity_form").serialize(),
                type: "POST",
                dataType: "json",
                success: function (result) {
                    if (result.is_succ) {
                        alert('修改成功');
                        window.location.reload();
                    } else {
                        alert("修改失败;" + result.error_msg);
                    }
                }
            });
        }
    url(r'^super_manage/save_shop_claritytype/$', 'supercenter.views.save_shop_claritytype'),


@login_required_superuser
def save_shop_claritytype(request):
    """
    修改店铺直播清晰度
    :param request: Http请求
    :return: Http响应
    """
    results = dict()
    try:
        shop = Shop.objects.get(pk=request.POST['shop_id'])
        logger.info(request.POST['live_clarity'])
        with transaction.atomic():
            shop.clarity_type = request.POST['live_clarity']
            shop.save()
        results['is_succ'] = True
    except Exception as e:
        results['is_succ'] = False
        results['error_msg'] = e.message
    return HttpResponse(json.dumps(results), mimetype='application/json')

 

标签:shop,save,request,弹出,results,修改,HTML,POST,clarity
来源: https://www.cnblogs.com/wuliaikun/p/13651579.html