Following this topic I'm still having an issue with it. I get the response with the correct stateId, but it doesnt parrsed it to query.
Inspecting the city dropdown, it display like this
<select class="required-entry" name="billing[city]" id="billing:city">
<option value=""></option>
[object Object]
</select>I've modified IndexController.php to the following since the one from topic didnt work
<?php
class Zeo_Citydropdown_IndexController extends Mage_Core_Controller_Front_Action{
public function getCitiesAction($selectedCity = '',$stateId = ''){
$result=array();
$result['mycities'] = $this->getRequest()->getParams();
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
}
?>Response from firebug
{"mycities":{"state_id":"278","default_city":"TestCity"}}Tks for your time
Hi,
We have made an extesnion for this. It is available here.http://www.magentocommerce.com/magento-connect/city-dropdown.html
Good luck!
Hi there,
If you are searching this feature for Magento 2, This is an extension called City Dropdown in Magento 2 https://github.com/php-cuong/magento2-city-dropdown.
I hope it can save your time.
Best Regards,
Cuong Ngo
Confirm that you perform this steps well.
Step3: modify script code to get json data.
Change code
onSuccess: function (data) { $('billing:city').replace('<select id="billing:city" name="billing[city]" class="required-entry">' + '<option value=""></option>' + data.responseText + '</select>'); }
To
onSuccess: function (data) { /* add this code */ var myjson=data.responseText.evalJSON(true); $('billing:city').replace('<select id="billing:city" name="billing[city]" class="required-entry">' + '<option value=""></option>' + myjson.mycities + '</select>'); }