Ajax Call之后页面卡住了

时间:2016-08-24 21:32:41

标签: javascript jquery html ajax

所以这是我的形式

<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;
               }

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:2)

假设您想要隐藏在

中引用的模态ID
var modalId = "exampleModal1_" + "{{ linq_order_num }}"; 

变化:

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

分为:

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

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