出现错误
new_ Uncaught ReferenceError: get_class_sections is not defined(…)
在ajax的onchange函数中,我如何解决这个问题,目前为止看到的分辨率不适用于我。
<div class="form-group">
<label class="col-sm-3 control-label">State</label>
<div class="col-sm-5">
<select name="state" class="form-control select2" style="width:100%;" data-validate="required" id="State"
data-message-required="State Required" onchange="return get_state_cities(this.value)">
<option value="">Select</option>
<?php
$notarray = DataDB::getInstance()->select_from('state');
foreach($notarray as $row):
?>
<option value="<?php echo $row['state'];?>"> <?php echo $row['state'];?> </option>
<?php
endforeach;
?>
</select>
</div>
</div>
ajax函数<script type="text/javascript">
function get_state_cities(state) {
$.ajax({
url: 'func.php',
data: { param1: state, action: city}
success: function(response)
{
jQuery('#city_selector_holder').html(response);
}
});
}
对于遇到同样问题的人,您的ajax函数应该是这样的
script type="text/javascript">
function get_state_cities(state) {
$.ajax({
url: 'func.php',
data: {stat: state},
success: function(data)
{
jQuery('#city_selector_holder').html(data);
}
});
}