2013-02-16 60 views
0

我試圖執行AJAX完整的事件裏面的一些代碼,但它不會在頁面加載事件工作後不執行,但它完美的作品在Onchange鏈接事件代碼jQuery的AJAX完整的事件

$(document).ready(function() { 
    $.ajax({ 
     beforeSend: function() { 
     // Handle the beforeSend event 
     }, 
     complete: function() { 
      // Handle the complete event 
      $("#customfields_1 :input").filter(function() { 
       return $.trim(this.value).length === 0; 
      }).closest("td").hide(); 
     } 
     // ...... 
    }); 
}); 
+3

可能是因爲你缺少一個URL請求發送到? – adeneo 2013-02-16 01:57:13

+0

@adeneo它不會在頁面加載事件工作,但它完美的作品在Onchange鏈接事件 – user2077308 2013-02-16 01:59:12

+0

@adeneo你能更具體 – user2077308 2013-02-16 02:00:05

回答

0
$(document).ready(function() { 
    $.ajax({ 
     url: 'http://foo.bar.com/some.json', // this is the important part 
     beforeSend: function() { 
     // Handle the beforeSend event 
     }, 
     complete: function() { 
      // Handle the complete event 
      $("#customfields_1 :input").filter(function() { 
       return $.trim(this.value).length === 0; 
      }).closest("td").hide(); 
     } 
     // ...... 
    }); 
});