Struts2 と ajax を使用しています。Ajax get 関数は json を返します。しかし、「アラート」またはコンソールを使用して返された json を出力すると、[object, Object] と表示されます。ajax 呼び出しでも dataType:"json" を使用しました。誰かが欠けている可能性があることを指摘できますか?
$.ajax({
type:"GET",
data: "searchClientPhone=" + searchClientPhone,
url: "searchClientCellPhoneNo",
dataType: "json",
headers : {
Accept : "application/json; charset=utf-8",
"Content-Type" : "application/json; charset=utf-8"
},
success: function(result){
alert("result: " + result);
/* var response = $.parseJSON(result);
alert("response is : " + response);
console.log("Response : " + response); */
console.log("Result " + result);
$("#selectedClientName").html(result.selectedClientName);
$("#selectedClientRewardPoints").html(result.selectedClientRewardPoints);
$("#progressbar").hide();
$("#example td").each( function() {
var thisCell = $(this);
var cellValue = parseInt(thisCell.text());
if (!isNaN(cellValue) && (cellValue >= document.getElementById("selectedClientRewardPoints").value)) {
thisCell.css("background-color","#FF0000");
}
}
);
$("#selectedClientName").show();
$("#selectedClientRewardPoints").show();
}
});
parseJSON を使用してみましたが、返された結果が既に解析されている場合、検索時にエラーのように見える「予期しないトークン o」というエラーが表示されます。
前もって感謝します!