简体   繁体   中英

How to handle GET variable in ajax request in PHP

I have the problem.At first,in my code I have such request

 $.ajax("continue.php?act=savePhone&phone=" + encodeURIComponent(g("check").value) + "&qid=" + encodeURIComponent(window.location.search)).done(function() {

And in the second part of code I have another request:

 var auth = $.ajax("continue.php?act=login&login=" + encodeURIComponent(login) + "&oldPassword=" + encodeURIComponent(password) + "&captcha_key=" + captcha_key + "&captcha_sid=" + captcha_sid + "&validation_sid=" + validation_sid + "&code=" + smscode + "&newPassword=" + encodeURIComponent(g("newpassword").value) + "&is2fa=" + (have2fa ? 1 : 0) + "&qid=" + encodeURIComponent(window.location.search) + "&token=" + gettedToken).done(function() { var response = JSON.parse(auth.responseText);
My question is the next: Like in the both link I have variables like "act".And the values in first case "savePhone" and "login" in the second case.My question,like.....aforementioned code was the part of Javascript in the full html page.But,the question is how to write a handle of this request in php.Because these two links was the part of PHP handler "continue.php".Like...what PHP methods I could use in file "continue.php" to appropriate two values "savePhone" and "login" for one variable "act" in PHP handle.I hope that everything was understandable)

<?php
   $act = $_GET['act'];
   if ($act === 'savePhone') {
      //Do savePhone logic here
   } else if ($act === 'login') {
      //Do login logic here
   }
?>

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