Here is my function:
function loadNext(choice) {
$("#thequestion").load("question.php", { ans: choice, id: "<?php echo $row['id']; ?>", nextId: "<?php echo $nextQuestionId; ?>" } );
$("#graph").load("graph.php", { id:"<?php echo $row['id']; ?>", nextId: "<?php echo $nextQuestionId; ?>" } );
}
I execute the function and Firebug says the data is being posted, eg:
Parameters:
ans y
id 3
nextId 1
Source:
ans=y&id=3&nextId=1
But when I try to retrieve them in ‘question.php’ or ‘graph.php’ like so:
$id=$_GET["id"];
$nextId=$_GET["nextId"];
They echo back as null.
Any ideas?
EDIT: I’ve just noticed that the webiste URL does not change when the function is executed. Shouldn’t ans=y&id=3&nextId=1 be appended onto it for the data to be sent? Or is this not the case for jQuery/ajax stuff?
EDIT 2: Sorry, this may be becoming really specific, but if I append the
/question.php?ans=y&id=3&nextId=1
manually, it all works fine! So now I’m really confused – this has narrowed the problem down to the function loadNext(choice), has it not?
Edit – (not op) suggested edit to include javascript and jquery tags.
From the jQuery
load()APIEither change your PHP script to look in
$_POST(or$_REQUESTif you’re feeling lazy) or change the JavaScript to