My Javascript code is not working in chrome
I am writing ajax on my page to get the subcategories in the select option, depending on how the category option list is selected. In all browsers it works well, I see my request, response in the browser console ... but in chrome functions it doesn't even ring. Do you know what the problem is? Here is my code:
<td>
<span style="color: #898989;">Main categories</span>
<br />
<select style="width: 200px;">
<?foreach ($main_categories as $item){?>
<option onclick="get_sub_cat(<?=$item['id']?>,2);return false;" value="<?=$item['id']?>"><?=$item['title']?></option>
<?}?>
</select>
</td>
<td>
<span style="color: #898989;">Subcategories</span>
<br />
<select name="sub_cat" style="width: 200px;" id="prod_subcat_2">
</select>
</td>
function get_sub_cat(id, select_id){
$.ajax({
type: "POST",
url: "<?=base_url()?>admin/product/get_sub_cat/"+id,
data: "",
success:function (option_list) {
$("#prod_subcat_"+select_id).children().remove();
$('#prod_subcat_'+select_id).append(option_list);
}
});
}
source to share
1) If you are running a local folder and not running on the server then chrome has reasons why you don't need to run these javascript calls. There are several threads around about running local javascript ajax calls on chrome, if so.
2) Try javascript with a simple warning ("hey"); to check if javascript or its ajax is working.
3) If javascript works. Use google "Developer Tools" ctrl + shift + i, set a breakpoint on your javascript call and check what is passed as a variable and there is a problem.
4) If javascript doesn't work try http://support.google.com/chrome/bin/answer.py?hl=en&answer=114662
source to share