Avatar of Marco Gasi
Marco Gasi
Flag for Spain

asked on 

javascript function return problem

Hi all.
I have a probably stupid problem I can' sove by myself :-(
I have this function which returns a number:
function getFolderCardsNumber(folder) {
		type: 'post',
		url: 'script.php',
		data: {folder: folder},
		success: function (result)
			var response = JSON.parse(result);
			console.log('in folder ' + folder + ' there are '+response + ' cards');
			return response;
		error: function (result)

Open in new window

The value in console is correct, so it looks to work fine. But here  I get undefined!
jQuery(document).ready(function ()
	var pc_cards_number, sp_cards_number;
	pc_cards_number = getFolderCardsNumber('PC');
	console.log('inner PC is '+pc_cards_number);
	sp_cards_number = getFolderCardsNumber('SP');
	console.log('inner SP is '+sp_cards_number);

Open in new window

Thnk you so mutch.

Avatar of undefined
Last Comment
Marco Gasi

8/22/2022 - Mon