gpt4 book ai didi

javascript - Ajax 调用后页面卡住

转载 作者:行者123 更新时间:2023-12-02 14:14:47 26 4
gpt4 key购买 nike

这就是我的表格

<form  action="javascript:void(0);"   class="form-inline"  id="receive-order-form"> By Receiving you agree that you have received the item <b> {{ x.item_name }} </b> at the store. </br> Order Id  <b> {{ x.order_id }}   </b></br><input class="btn btn-primary center-block" onclick="execute({{x.linq_order_num}})" type="submit" id= 'receive-btn' value="Receive" ></form>

提交后,远程调用被执行,我弹出成功消息,但不知何故屏幕卡住了。页面变得无响应。 Page becomes unresponsive after ajax call success.

执行函数定义:

    function execute(linq_order_num) {
var result = "";
var tableRow=document.getElementById("order_num1_"+String(linq_order_num));
var modalId = "exampleModal1_" + "{{ linq_order_num }}";
jQuery.ajax ({
url: "/receive-order/",
type: "POST",
data: JSON.stringify({"linq_order_num":linq_order_num}),
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function(data){
result = data;
$("#modalId").modal('hide');
$('#alert_placeholder').html('<div class="alert
alert-success"><a class="close" data-
dismiss="alert">&times;</a>
<span>Successfully received the product</span>
</div>');
var htmlElement = document.getElementById("deliver-
order_"+ String(linq_order_num));
var cln = htmlElement.cloneNode(true);
cln.style.display = null;
tableRow.cells[7].innerHTML = cln.outerHTML;

}
});
return result;
}

我该如何解决这个问题?

最佳答案

假设您想要隐藏引用的模态 ID:

var modalId = "exampleModal1_" + "{{ linq_order_num }}"; 

更改:

$("#modalId").modal('hide');

进入:

$("#" + modalId).modal('hide');

在当前版本中,您试图隐藏 HTML 中 id="modalId" 的元素。

关于javascript - Ajax 调用后页面卡住,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39133359/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com