将href中的name值发布到另一个php页面

时间:2016-10-14 09:58:39

标签: php jquery html

我想更改选中的文字标记,点击链接后发送,并将$ oid数据发布到updategoingorder.php。

$(".waves-effect3").click(function() {
  var addressValue = $(this).attr("id");
  var oid = $(this).attr("name");
  $(".waves-effect3").text("Mark Delivered");
});
alert(oid);
$.ajax({
  type: 'POST',
  url: 'updategoingorder.php',
  data: {
    'id': addressValue,
    'name': oid
  },
  success: function() {

    alert("Status Updated!!!");
  }
});
});
<td><a href="#" name="'.$oid.'" class="waves-effect3" id="'.$data[$i]['name'].'"><i class="fa fa-check"></i><span>Mark Picked</span></a>
  <br>

2 个答案:

答案 0 :(得分:1)

你的代码似乎很好,除了很少的问题,

  • Ajax函数应该在Z
  • 您将无法访问该功能之外的变量click function()

addressValue, oid
$(".waves-effect3").click(function() {
   var addressValue = $(this).attr("id");
   var oid = $(this).attr("name");
   console.log(oid);  
   console.log(addressValue);
   $(".waves-effect3").text("Mark Delivered");
  
   $.ajax({
      type: 'POST',
      url: 'updategoingorder.php',
      data: {
        'id': addressValue,
        'name': oid
      },
      success: function() {
        alert("Status Updated!!!");
      }
    });
});

答案 1 :(得分:0)

你应该试试这个:

$(document).ready(function(){
            $(".waves-effect3").click(function() {
              var addressValue = $(this).attr("id");
              var oid = $(this).attr("name");
              $(".waves-effect3").text("Mark Delivered");
            });
            alert(oid);
                $.ajax({
                  type: 'POST',
                  url: 'updategoingorder.php',
                  data: {
                'id': addressValue,
                'name': oid
                  },
                  success: function() {

                alert("Status Updated!!!");
                  }
                });
            });
            });
相关问题