Onchange function not working using laravel5.here i select the second category from same table.i can get the first category id.onchange function is the problem.what i need to change. Controller
public function ajax_select_sub_second_cat()
{
$id = $_GET['id'];
$main_cat = Category_model::get_sub_category_ajax($id);
//return view('siteadmin.add_cat',['main_cat' => $category]);
if($main_cat)
{
$return = "";
$return = "<option value='0'> -- Select -- </option>";
foreach($main_cat as $main_cat_ajax) {
$return .= "<option value='".$main_cat_ajax->sub_category1."'> ".$main_cat_ajax->sub_category1." </option>";
}
echo $return;
}
else
{
echo $return = "<option value='0'> --Select-- </option>";
}
}
view
<select id="subcategory" name="product_sub_category" onChange="getCat1(this.value);">
-----Select Standard-----
<script>
function getCat1(id)
{
var passData = 'id='+id;
$.ajax( {
type: 'get',
data: passData,
url: '<?php echo url('ajax_select_sub_second_cat'); ?>',
success: function(responseText){
if(responseText)
{
$('#subcategory2').html(responseText);
}
}
});
}
</script>
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire