JQuery/Ajax 呼び出しで Struts アクションからリストを返し、s:iterator を使用してリスト要素を DIV に入力するためのちょっとした助けを探しています。
私は次のJQueryを持っています
function lookupCustomerJs() {
alert("lets start");
$.ajax({
type: "POST",
url: "lookupCustomerAjax",
data: $('#lookupCustomer').serialize(),
success:function(response) {
alert("do stuff");
$('div#custList').replaceWith($(response).find("div#custList"));
},
failure:function(response) {
alert('Ajax call failed');
},
error:function(response) {
alert(exception);
}
});
}
ページ内に DIV があり、リストを反復処理したい
<div id="custList">
<s:iterator status="stat" value="customerList" var="customer">
<s:param name="custFName" value="%{customer.firstname}" />
</s:iterator>
</div>
そして、IS が呼び出された私の Action メソッドは、デバッグ時にデバッガーがコードを通過するためです。
private List<Customer> customerList;
public String lookupCustomerAjax() {
dummyData();
return SUCCESS;
}
これにより、Action メソッドが正常に呼び出されますが、取得できるのは「始めましょう」というアラートだけで、それ以外には何もエラーもエラーもありません。
したがって、jQuery/Ajax success:function(response) { が正しく起動していないだけだと推測していますが、その理由はわかりません。