weixin_33728708 2018-12-30 23:07 采纳率: 0%
浏览 22

发送特定数据到ajax

i want to post a variable data to ajax post this is my html code

<tr>
                <td class="text-right">Payment ID:</td>
                <td>variable</td> // variable that i want to post
              </tr>

and this is my java script code

var ajax_call = function() {
      $.ajax({
                    type:"post",
                    url:"request-handler.php",
                    data:{
                    
                    data:"Payment ID"
                    
                    }
                });


};

var interval = 5000; // where X is your every X minutes

setInterval(ajax_call, interval);

now i want to post the variable that between td tags in the ajaxpost

</div>
  • 写回答

2条回答 默认 最新

  • weixin_33711641 2018-12-30 23:21
    关注
    <tr id="rowID">
      <td class="text-right">Payment ID:</td>
      <td>variable</td> // variable that i want to post
    </tr>
    

    and in your javascript

    var ajax_call = function() {
          $.ajax({
               type:"post",
               url:"request-handler.php",
               data:{
                        var Row = document.getElementById("rowID");
    var Cells = Row.getElementsByTagName("td");
                        data:Cells[1].innerText
    
                        }
                    });
    
    
    };
    

    EDIT: You can directly use var cells = document.getElementsByTagName("td"); as well. OR set and id to cell <tr > <td class="text-right">Payment ID:</td> <td id="columnID">variable</td> // variable that i want to post </tr>

    data:{document.getElementById("columnID")}

    评论

报告相同问题?