Ajax not returning value back to the calling script
Hello,
After 5 days of picking at the code I excepted defeat and come seeking help..lol
Working on a user registration form and in it i have 2 dropdown list, one for country and one for state/province.
On page load the country dropdown list is loaded and it works.
When a user selects a country the state/province dropdown list successfully loaded and this also works.
Not working:
in the event the user submits the form I like to have the states/province reloaded with the initial selection at the top of the menu list. As of now i cant even reload the state/prv dropdown list if the user hits the submit button.
any help you can provide would be greatly appreciated.
tk
- <label>Select province (required field)</label><br/>
- <select name="sel_Iprovince" id="IprovinceID">
- <option value="">Select Province</option>
- <?php
- if (!empty($_POST['sel_Iprovince'])){
- echo "<script> getProvince('" . $_POST['sel_Icountry'] . "', '" . $_POST['sel_Iprovince']. "'); </script>";
- }
- ?>
- </select>
- function getProvince(countryVal, provinceId) {
- var GeoCountry = countryVal;
- var GeoProvince = provinceId;
- alert('test1=:'+GeoCountry+' '+ GeoProvince);
- $.ajax({
- type: "POST",
- url: "get_tprovince.php",
- data: {'GeocountryID': GeoCountry, 'GeoprovinceID': GeoProvince},
- success: function(data){
- if(typeof(GeoCountry) !== 'undefined'){
- alert('test2=:'+ data);
- $("#IprovinceID").html(data);
- }
- if(typeof(GeoProvince) !== 'undefined'){
- alert('test3=:'+ data);
- $("#IprovinceID").html(data);
- }
- }
- });
- }