PHP + JS按钮值保存

Logic is that , on click div.buttons gonna hide and get second form : save date to mysql .. problem is in this : 1) i have to save grab name or value from buttons : problem no refresh page . i tried send date to php with ajax , with GET or POST methodes from js .. buttons are taken mysql and echoed in php like this :
PHP: foreach ($res as $row) { echo '<tr><td><button id="pupShow" name="'.$row["ID"].'">'.$row["SubjectName"].'</button> </td></tr>'; }


JS: $("button#pupShow").click(function () { $("div.pupInput").show("slow"); $("div.showMarks").toggle("slow"); $("div.lessons").toggle("slow"); alert(this.name); // $GLOBALS['myglob'] = this.name; // window.location.href ="subID.php?subID="+this.name; // return false;
this is js were i handle click on button
any help ?
i got eye on transforming first buttons into selected manue . so i could grab them by name from php , but its destroy my visual ..

So you want to submit some data without refreshing the page? Since you're using jQuery, you can do something like this:

$.post("test.php", {name: "Mathematics"}).done(function(data) {
    console.log("Response loaded: " + data);
});

If you don't want to reload the page, then you can try:

foreach ($res as $row) {
        echo '<tr><td><button id="pupShow" name="'.$row["ID"].'" onclick="return false;">'.$row["SubjectName"].'</button> </td></tr>';
   }

or

$("button#pupShow").click(function (el) {
   el.preventDefault();

   var data = 'nume=' + el.val()

   $.ajax({
       url: "subID.php",
       type: "POST",
       data: data,
       cache: false,
       success: function (html) {
           if (html) {
               // animations here
               alert('Success! Form submitted');
           } else{
               alert('Error! Please try again');
           }
       }
   });

I didn't test it but it should help you understand how the function will look like.