I am trying to send 2 variables in a JQuery Ajax call, but for some reason, both variables end up bundled in the first one:
function getNextQuestion(answer, queryType)
{
$.ajax
({
async: false,
url: 'handlers/question_hdlr.php',
type: 'POST',
data: "answer="+ answer +"&queryType=" + queryType,
dataType: "json",
success: function(result)
{
...
},error: function(XMLHttpRequest, textStatus, errorThrown)
{
alert ("error: "+textStatus);
}
});
return false;
}
When I run it in the debugger, I get only one variable:
$_POST["answer"], containing "answerqueryTypequeryType"
$_POST["queryType"] does not exist.
What am I doing wrong?
Just found out that there is nothing wrong in the code in the question, the only problem was that the Javascript file cached by the browser contained a typo and even though the problem was fixed on the working copy, the browser was never actually running it.
The solution was to add the date & time to the script url as a parameter to prevent the browser from using the cached version:
This works fine.