需要你help.I想寫像阿賈克斯<C:IF>
一些JSTL代碼,但它合乎理不行JSTL在AJAX不起作用
function myfunction(cd){
$("#datatable tbody").empty();
$.ajax({
url :'/KurirCC/management-user-by-request.html',
cache :true,
data :{"kode":cd},
dataType :"json",
type : "GET",
contentType : "application/json; charset=utf-8",
success : function(jsondata){
$.each(jsondata.data,function(i,obj){
var status = obj.sts;
tableHtml ="<tr> <td>"+ obj.id_mobile + "</td> <td>" + obj.nama +"</td> <td>"+ obj.username +"</td> <td>"
+ obj.kota + "</td> <td><c:if test="${status == 1}">Aktiv</c:if></td><td align='center'><button type='button' class='btn tom-history' title='History' ></button></td> </tr>";
$(tableHtml).appendTo('#datatable tbody');
});
}
});
}
這段代碼<td><c:if test="${status == 1}">Aktiv</c:if></td>
不行, 其中問題在哪裏?
這是沒有意義的。有關如何工作的基本解釋,請參閱重複內容。 JavaScript有它自己的'if()'語句。利用它。 – BalusC