gvhjb 2021-05-17 12:44 采纳率: 75%
浏览 98
已采纳

ajax里的el表达式要怎么写呀?

jsp里的代码:
<td><span class="td_special" title="查看产品详情"><a href="javascript:void(0)" onclick="getChildPage(this)">详情</a></span>
<span class="td_special" title="删除产品"><a href="${pageContext.request.contextPath}/order/deliveryss/${product.product_id}">删除</a></span></td>
<td hidden><span class="product_id">${product.product_id}</span></td>

ajax里写的是这样:

tbody.append("<tr><td><input type='checkbox' class='cbx_select' id='cbx_product_select_" + product_id + "'><label for='cbx_product_select_" + product_id + "'></label></td><td title='"+product_name+"'>" + product_name + "</td><td title='"+product_title+"'>" + product_title + "</td><td title='"+product_price+"'>" + product_price + "</td><td title='"+product_sale_price+"'>" + product_sale_price + "</td><td title='"+product_create_date+"'>" + product_create_date + "</td><td><span class='" + isEnabledClass + "' title='"+isEnabledTitle+"'>"+ isEnabled +
    "</span></td><td><span class='td_special' title='查看产品详情'><a href='javascript:void(0);' onclick='getChildPage(this)'>详情</a></span>"
    + " "+ "<span class='td_special' title='删除产品'><a href='${pageContext.request.contextPath}/order/deliveryss/${product.product_id}'>删除</a></span></td><td hidden><span class='product_id'>"
    + product_id + "</span></td></tr>");

jsp里的删除方法是好用的 一点击下一页触发ajax方法后 删除方法就不好用了 是哪里写错了吗

  • 写回答

2条回答 默认 最新

  • 崽崽的谷雨 2021-05-17 12:47
    关注

     

    (`<tr><td><input type='checkbox' class='cbx_select' id='cbx_product_select_" + product_id + "'><label for='cbx_product_select_" + product_id + "'></label></td><td title='" + product_name + "'>" + product_name + "</td><td title='" + product_title + "'>" + product_title + "</td><td title='" + product_price + "'>" + product_price + "</td><td title='" + product_sale_price + "'>" + product_sale_price + "</td><td title='" + product_create_date + "'>" + product_create_date + "</td><td><span class='" + isEnabledClass + "' title='" + isEnabledTitle + "'>" + isEnabled +
                "</span></td><td><span class='td_special' title='查看产品详情'><a href='javascript:void(0);' onclick='getChildPage(this)'>详情</a></span>"
                + " " + "<span class='td_special' title='删除产品'><a href=${pageContext.request.contextPath}/order/deliveryss/${product.product_id}>删除</a></span></td><td hidden><span class='product_id'>"
                + product_id + "</span></td></tr>`)

    ${}是es6语法模板字符串,有了这个就不用字符串拼接了,直接用模板字符串

    或者字符串拼接

     tbody.innerHTML=("<tr><td><input type='checkbox' class='cbx_select' id='cbx_product_select_" + product_id + "'><label for='cbx_product_select_" + product_id + "'></label></td><td title='" + product_name + "'>" + product_name + "</td><td title='" + product_title + "'>" + product_title + "</td><td title='" + product_price + "'>" + product_price + "</td><td title='" + product_sale_price + "'>" + product_sale_price + "</td><td title='" + product_create_date + "'>" + product_create_date + "</td><td><span class='" + isEnabledClass + "' title='" + isEnabledTitle + "'>" + isEnabled +
                "</span></td><td><span class='td_special' title='查看产品详情'><a href='javascript:void(0);' onclick='getChildPage(this)'>详情</a></span>"
                + " " + "<span class='td_special' title='删除产品'><a href="+pageContext.request.contextPath+'/order/deliveryss/'+product.product_id+">删除</a></span></td><td hidden><span class='product_id'>"
                + product_id + "</span></td></tr>");
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效