I have a js switch declaration that checks if a specific string is present in the submitted text.
var textA= //regex
var textB= //regex
switch(true) {
case textA.test(input):
// CASE A
$ajax ({
type:"post",
url:"process.php",
data: {input:input,age:age,city:city,type:type},
success: function(html){alert(html);} });
break;
case textB.test(input):
// CASE B
$ajax ({
type:"post",
url:"process.php",
data: {input:input,width:width,height:height,type:type},
success: function(html){alert(html);} });
break;
case ...
}
normally, i would create dedicated php file to handle the POST data for each of $ajax.
but how can i handle multiple $ajax POST in a single php.
i included a unique identifier type: for each ajax data, this will be my reference as to what ajax is being received by my PHP
but im not sure how to properly code PHP to handle the submitted $_POST type.
<?php
//get post type from submitted AJAX
$type = $_POST;
switch($type) {
case 0:
$type= "caseA"
//some code here
case 1:
$type= "caseB"
// some code here
}
?>