2015-11-19 45 views
-2

我必須根據複選框在mysql表中設置0和1,如果它是否檢查。 我正在使用jquery ajax函數, 但jquery函數下面沒有傳遞數據到php文件。請你糾正我的代碼。不能通過任何變量通過jquery ajax

$(document).ready(function(){ 
$("input.active").click(function() { 
// store the values from the form checkbox box, then send via ajax below 
var check_active = $(this).is(':checked') ? 1 : 0; 
var check_id = $(this).attr('value'); 
    $.ajax({ 
     type: "GET", 
     url: "dynamicupdateicube.php", 
     data: {id: check_id, active: check_active} 
     success: function(){ 
      alert("updated"); 

     } 
    }); 

}); 


}); 

這將是很好,如果你能拯救我的生命。

+1

語法錯誤的數據線和 後面的逗號:缺少','後'數據:{ID:check_id,活躍:check_active}' – Tushar

+0

有一個語法錯誤,並確保你已經添加了一個jQuery庫 –

+0

@nehaJ歡迎!在開發保持瀏覽器控制檯處於打開狀態時,請使用能夠首先檢測這些錯誤的_smart_編輯器,請使用[jslint](http://www.jslint.com/)或[jshint](http://jshint.com/ ) – Tushar

回答

1
$.ajax({ 
     type: "GET", 
     url: "dynamicupdateicube.php", 
     data: {id: check_id, active: check_active}, 
     success: function(){ 
      alert("updated"); 

     } 
    }); 

你已經錯過了將一個,data: {id: check_id, active: check_active}

+0

請不要回答這樣的問題,接近TYPO – Tushar

+0

不錯的想法... – void

+0

Off-course,這是基本的語法錯誤。 –