【问题标题】:Struts2 to ajax json response how to set image on Jsp pageStruts2到ajax json响应如何在Jsp页面上设置图像
【发布时间】:2015-01-01 10:57:44
【问题描述】:
Struts2 to ajax json response can we set it on jsp first and display jsp as response inside

ajax 成功 这是在 jquery 中使用动态值编写 jsp/html 标记变得非常痛苦的代码,所以有什么方法可以在响应后在 jsp 中显示 html 并返回 jsp 或显示在 function(response){ }.

        $.post("add_cmt?content1="+comment_text+"&postupload_id1="+getpID, {
        }, function(response){
            $('#CommentPosted'+getpID).prepend("<div>"+'<img src="images/'+comment_userid+"/"+comment_album+"/"+comment_pic +'" width="50" height="50" />'+"<b>"+comment_name+"</b>"+"   "+comment_text+"<br/>"+"few Seconds ago"+"</div>");

        });

【问题讨论】:

    标签: javascript jquery ajax jsp struts2


    【解决方案1】:

    是的,我们可以在 ajax 响应中发送 jsp/html 页面

    创建一个您想要作为响应的 jsp 页面,然后在任何 div 中的 $post 成功显示响应

     $.post("add_cmt?content1="+comment_text+"&postupload_id1="+getpID, {
            }, function(response){
                $('#CommentPosted'+getpID).prepend(response);
    
            });
    

    Ajax jsp

    您的内容

    查看这个以获得更好的解释 http://ebhor.com/html-jsp-page-response-in-ajax-get-method/

    【讨论】:

      猜你喜欢
      • 2016-05-17
      • 2020-04-08
      • 2017-03-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-19
      • 2013-10-11
      相关资源
      最近更新 更多