Title may not be correct, tried my best to explain the issue. Spent hours trying to figure this, and I can't.
I basically have a JS function with an AJAX call within it.
function doAjax(input) {
$.ajax({
url: "validate.php?input=" + input,
data: $("form").serialize(),
dataType: 'json',
type: 'POST',
async: false,
success: function (data) {
alert(data.input);
}
});
}
I want to alert data from json based on the input parameter.
alert(data.(THIS SHOULD BE THE FUNCTION PARAMETER));
Currently, it returns undefined because data.input isn't defined.
EG: If the function is called like this: doAjax("username");
The alert should be data.username.
I hope this makes sense, and I hope someone can help. Thanks!