create a list of zones

<select name="shipping_zone" id="shipping_zone"> <option value="0">- выберите область -</option> <?php foreach ($zones as $zone) { ?> <?php if(!empty($zone['id_area'])){ ?> <option value="<?php echo $zone['id_area'] ?>" ><?php echo $zone['name']; ?></option> <?php } ?> <?php } ?> </select> 

after selecting the zone I want to load html via Ajax

 $("#shipping_zone").change(function () { var zone = parseInt($("#shipping_zone").val()); console.log(zone); getCodeNovaposhtaCities(zone); }); function getCodeNovaposhtaCities(zone) { var city = $("#shipping_city"); $("#divregion").fadeIn("fast"); city.attr("disabled", false); if(zone > 0){ } city.load( "order_change.tpl", {zone: zone}, ); } 

but for some reason goes null

 public function getCodeNovaposhtaCities(){ $zone = $_POST['zone']; $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "novaposhta_cities` WHERE Area ='". $zone. "'"); //print_r($query);die; return $query->rows; } 
  • where does null come out? Please show the client function code getCodeNovaposhtaCities - Igor
  • public function getCodeNovaposhtaCities () {$ zone = $ this-> request-> post ['zone']; $ query = $ this-> db-> query ("SELECT * FROM " . DB_PREFIX . "novaposhta_cities WHERE Area = '". $ zone. "'"); // print_r ($ query); die; return $ query-> rows; } $ zone = NULL That should come from the selection of a region, - Roman Yushko
  • $ (document) .ready (function () {$ ("# shipping_zone"). change (function () {var zone = ($ ("# shipping_zone"). val ()); console.log (zone); getCodeNovaposhtaCities (zone);});}); function getCodeNovaposhtaCities (zone) {var city = $ ("# shipping_city"); $ ("# divregion"). fadeIn ("fast"); city.attr ("disabled", false); if (zone> 0) {} city.load ("order_change.tpl", {zone: zone},); } - Roman Yushko
  • Please put the code in question by editing it. - Igor
  • And what will happen when you get 105; DROP TABLE novaposhta_cities according to getu 105; DROP TABLE novaposhta_cities 105; DROP TABLE novaposhta_cities ? Well, or something more interesting. sqlmap.org This thing can automatically download your entire database and upload something like metasploit.com ... Read about SQL injection - E_p

1 answer 1

http://api.jquery.com/load/ :

equivalent to $ .get (url, data, success)

 $zone = $_GET['zone'];