weixin_33743880 2012-06-14 16:40 采纳率: 0%
浏览 41

jQuery-Ajax-Struts2列表

Im looking for a little help on getting my JQuery/Ajax call to return a List from a Struts action and populate a DIV with the list elements using s:iterator.

I have the following 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);
            }
        });  
    }

I have a DIV within my page which I then want to iterate the list through

                        <div id="custList">
                            <s:iterator status="stat" value="customerList" var="customer">
                                <s:param name="custFName" value="%{customer.firstname}" />
                            </s:iterator>
                        </div>

And my Action method which IS called, because when I debug, the debugger goes through the code.

private List<Customer> customerList;

public String lookupCustomerAjax() {

    dummyData();

    return SUCCESS;
}

This successully calls my Action method, but all I get is the "lets start" alert, then nothing else, no errors, nothing!

So I'm guessing it's just the jQuery/Ajax success:function(response) { not fireing correctly, but can't see why.

  • 写回答

1条回答 默认 最新

  • weixin_33670713 2012-06-14 16:56
    关注

    It is probably the "lookupCustomerAjax" is an invalid url or file name. You should try adding the extension.

    Also, for troubleshooting, you should console.log(response) in your succession to see that you are actually get the result.

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器