简体   繁体   中英

passing parameter with js/ajax to a php document

$(document).ready(function()
{
$(":input").focusout(function () {

    var a= $(this).closest("tr").attr('id');
    var b= $(this).closest("td").attr('id');
    var data = $(this).attr("value");

   $.post("database.php",
   {trAdress: a, tdAdress: b }, function(data){ alert("Data Loaded: " + data); }); });}); 

I want to pass trAdress and tdAdress also data parameters to a php document... Can anyone help me how can I get these parameters in a php document_?

它们将在$_POST数组中设置为$_POST['trAdress']$_POST['tdAdress']

If you sent them using POST, you can access the values sent in the form using $_POST superglobal variable:

<?php
$trAddress = $_POST['trAddress'];
$tdAddress = $_POST['tdAddress'];

// your code here

http://php.net/manual/en/reserved.variables.post.php

$_POST["trAdress"]$_POST["tdAdress"]将为您提供值

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM