success: function(jsonresponse) {
data = JSON.stringify(jsonresponse);
$.each(JSON.parse(data), function (index, item) {
var Id=item.id;
var JobId=item.JobId;
var eachrow = "<tr>"
+ "<td>" + item.id + "</td>"
+ "<td>" + item.JobId + "</td>"
+ "<td>" + item.UserId + "</td>"
+ "<td>" + item.updatedAt + "</td>"
+ "<td>" + "<button onclick='myFunction(JobId,Id, \"accepted\")' class='btn btn-success btn-block'>Reject</button>" + "</td>"
+ "<td>" + "<button onclick='myFunction(JobId,Id, \"rejected\")' class='btn btn-success btn-block'>Reject</button>" + "</td>"
+ "</tr>";
$('#tbody2').append(eachrow);
});
},
myFuntion(的JobId,ID,\「接受\」)不與變量可以作爲參數,但手動添加時則函數的工作,如myFuntion(1, 3,\ 「接受\」)。HTML按鈕的onclick功能不使用jQuery可變工作作爲參數
這是因爲你的變量作爲附加的方式是錯誤的按鈕字符串內按鈕的onclick屬性..! –