2012-02-13 94 views
0
$.get registered callback function is not working. 

var timer = setInterval(function() 
{ 
    $.getJSON("/resposweb/resposmonitor", {updt:updateTime}, function(data) 
    { 
     $.each(data,function() 
     { 
      updateTime = this.time; 
      var bActName; 

      if(this.act == 'D') 
       $('#'+this.idNo).remove(); 
      else 
      { 
       if(this.act == null) 
        bActName = 'Ack'; 
       else if(this.act == 'A') 
        bActName = 'Ready'; 
       var $ctrl = $('<button/>').attr({ type: 'button', name:'btn'}).addClass("btn").text(bActName).button().click(function() 
        { 
         $but = $(this)$.get("/resposweb/resposmonitor",  
          { 
           action:'update',mod:$but.val(),idNo:$but.parent().parent().attr('id') 
          }, 
          function(data) 
          { 
           console.log('data'); 
           $('#cont2').append('ddefe'); 
          }); 
        }); 
       var $td1 = $('<span/>').text(this.kot); 
       var $td2 = $('<span/>').text(this.tableNo); 
       var $td3 = $('<span/>').attr('class','items').text(this.itemDesc); 
       var $td4 = $('<span/>').text(this.qty); 
       var $td6 = $('<span/>').append($ctrl); 
       var $td5 = $('<li/>').attr('class','ui-widget-content').attr('id',this.idNo).append($td1).append($td2).append($td3).append($td4).append($td6);$td5.appendTo($("#selectable2")); 
      } 
     }); 
    }); 
},5000); 

是否有任何問題,我收到服務器的請求,我正確地發送響應。爲什麼這個函數沒有執行。我錯過了什麼嗎?jquery調用getJson的按鈕點擊

響應: 成功

+1

您可以添加有關您收到的回覆的信息嗎?在你的情況下,'數據' – Tx3 2012-02-13 12:18:56

回答

0

它可能是由一個語法錯誤引起的。檢查您的瀏覽器的JavaScript控制檯/錯誤日誌。