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条)

报告相同问题?

悬赏问题

  • ¥15 虚拟机打包apk出现错误
  • ¥30 最小化遗憾贪心算法上界
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝