Avatar of DanielAttard
DanielAttard
Flag for Canada asked on

Return value from jQuery Ajax call

Am trying to figure out how to return a value after making an ajax call.  In the example below, option 1 and option 2 both correctly return values, but I do not seem to be getting the same result with option 3.  Here's the code:
function getLevel(cat){
	if(cat==1){
		return $('#billed').val();
	}
	else if(cat==2){
		return <?php echo $prior; ?> 
	}
	else if(cat==3){
		var eventdate = $('#billed').val();		
                $.ajax({
                        url: sURL+"utility/eventDateAjax/"+eventdate,
                        type: "POST",                        
                        success: function(data){
                                alert(data);
                                return data;
                        }
                });
	}
}

Open in new window

Can someone tell me what I am doing wrong?  Thanks.
JavaScriptAJAXPHP

Avatar of undefined
Last Comment
Mrunal

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Mrunal

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Your help has saved me hundreds of hours of internet surfing.
fblack61