I'm having some trouble with a simple function that makes an ajax call to get the link for a specific category and then puts the value at an input.
My Ajax Call:
function GetCategoryInfo(){
var form = document.getElementById('add-info');
var formData = new FormData(form);
formData.append('caller', 'Info');
$.ajax({ url: '../inc/call.php',
enctype: 'multipart/form-data',
processData: false,
contentType: false,
cache: false,
data: formData,
type: 'POST',
success: function(output) {
console.log(output);
return output;
}
});
}
My function:
$('#card_category').change(function(){
$('#card_slug').val(GetCategoryInfo() + "/" + GetNameInfo());
CheckPokemonSlug();
})
Please ignore function GetNameInfo() since its working very well. My problem occurs when the change select item happens. It always fill the input with "undefined/text from function GetNameInfo()"
The worst thing it that the console.log outputs the right information that should be in the input form.
Any suggestions on this? Since I call the isn't this supposed to work. Get's the information and then set it to input.