I was wondering if all the relevant JQuery libraries are included by default, as I am having trouble trying to get this AJAX code to post. It doesn't do anything.
$(document).ready(function() { $("select.country").change(function(){ var selectedCountry = $(".country option:selected").val(); $.ajax({ type: "POST", url: "$core_v2_page.Url", data: { country : selectedCountry } }).done(function(data){ $("#response").html(data); }); }); });
And the velocity code:
#set($countries = false) #set($countries = $Ibby_v1_LocationData.GetAllCountries()) <form> <div> #if ($countries) <label>Country:</label> <select class="country"> <option>Select</option> #foreach ($country in $countries) <option value="$country.iso2">$country.country</option> #end </select> #else #end </div> <div> #if ($core_v2_page.IsPost) $core_v2_page.SetContentType('application/json') #set($country = false) #set($country = $core_v2_page.GetFormValue('country')) #if ($country) #set($regions = $Ibby_v1_LocationData.GetRegionsInCountry($country)) #if($country != 'Select') <label>Region:</label <select> #foreach($region in $regions) <option>$region</option> #end </select> #end #end #end </div> </form> <div id="response"></div> </div>
Edited
[edited by: IbrahimK at 12:01 PM (GMT 0) on Wed, Jul 22 2020]