在jQuery success函数中,将值传递给引导模式

时间:2020-12-30 19:37:53

I have a Bootstrap modal inside a jQuery success function. I want to show some value in the model.

我在jQuery成功函数中有一个引导模式。我想在模型中显示一些值。

My model:

我的模型:

<div class="modal fade" id="REQModal" role="dialog" data-backdrop="static" data-keyboard="false">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header btn-danger">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">Error Message</h4>
            </div>
            <div class="modal-body">
                 <div id="num"></div>
                <p>Error has occured!.</p>

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>

My function:

我的函数:

$.ajax({
                url: $('#addRequest').val(),
                type: "POST",
                data: { Request: Request },
                dataType: "json",
                success: function (refNo) { // refNo comes here.
                    $("#num").val(refNo);
                    $("#REQModal").modal('show'); // modal popup's but refNo doesn't show.
                }
            });

2 个解决方案

#1


3  

try:

试一试:

$("#num").html(refNo); 

instead of

而不是

$("#num").val(refNo);

#2


0  

Try this

试试这个

$("#num").html(refNo);

$(" # num "). html(refNo);

#1


3  

try:

试一试:

$("#num").html(refNo); 

instead of

而不是

$("#num").val(refNo);

#2


0  

Try this

试试这个

$("#num").html(refNo);

$(" # num "). html(refNo);