Can you print out the $_REQUEST ?
Also, maybe the problem is the data you are passing? shouldn't it be:
data:{QB:QB, function:'Save_Question'},
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
hi i tried to pass array value from jquery to php using ajax post method but its not working.
the ajax code:
QB['Title']=title;
QB['Qtype']=Qtype;
QB['Parrent']=Parrent;
QB['Child']=Child;
QB['options']=option;
$.ajax({
type:'post',
async:false,
url:'includes/feedback.php',
data:{QB:QBarray,function:'Save_Question'},
datatype:'json',
beforesend:function()
{
$(this).html('Please Wait...');
},
success:function(data)
{
let json=JSON.parse(data)
toast_message(json.Result,json.Message);
},
error:function(data)
{
console.log('Error');
},
complete:function()
{
$(this).html('Submit');
},
and PHP code is:
elseif($_REQUEST['function']=='Save_Question')
{
// $QB_array[] = $_REQUEST['QB'];
echo '<pre>';print_r(json_decode($_REQUEST['QB']));exit;
and got error like
Notice: Undefined index: QB in C:\xampp\htdocs\feedback\includes\feedback.php on line 33
Please or to participate in this conversation.