dongqiao1158 2014-12-10 09:23
浏览 42
已采纳

POST动态HTML表值到jQuery AJAX

I am trying to get all the values present in my dynamic HTML table and POST the values to AJAX.

I have HTML table like this

enter image description here

When i press '+' , I can able to add rows dynamically . When i click save, How to POST array values from this HTML table to AJAX, so that i can meanwhile INSERT those values into MYSQL

I have tried getting the 'text' of each td present in my table

var rows = $("tbody tr",$("#myTable")).map(function() { 
    return [$("td",this).map(function() { 
      return this.innerHTML;     
    }).get()];
  }).get();

This is getting me -> <input type="text"> and so on.

  • 写回答

3条回答 默认 最新

  • dsdfd2322 2014-12-10 09:31
    关注

    you are returning the innerHTML, which is... HTML. you can get the value of a input element with .val() how does this work for you?

    return $("td input").map(function() { 
      return $(this).val();     
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办