简体   繁体   中英

$.ajax( type: “POST” POST method to php file

I'm trying to use the POST method in jQuery to send mobile to a php file called save.php . So this is the code in the html page:

<script>
            function saveit(userid){

                var number = userid;
                number = number.replace(/[^0-9.]/g, "");

                var transaction = sendNumber(number);

                if(transaction === '0'){
                    //alert("Transaction Successfull");
                    console.log('Success');
                }else{
                    console.log('Failed');
                }


                userid=userid;
                $.ajax({
                  type: "POST",
                  url: "./ajax/save.php",
                  data: { userid: userid },
                  beforeSend: function (  ) {

                  }
                }).done(function ( data ) {
                    alert("Vielen Dank, Sie wurden erfolgreich registriert");
                    window.history.back();

                    if( console && console.log ) {
                    console.log("Sample of data:", data);
                  }
                });
                return false;
            }
</script>

My question is now, what should I write in save.php to see all the numbers?

您需要运行服务器,您是通过 xampp 或类似方式在自己的计算机上执行此操作,还是有托管服务提供商?

 <?php echo $_POST['userid']; ?>

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