谷歌浏览器中这个功能到底有什么不妥,虽然它在firefox中工作得非常完美,
function is_valid(type="") {
if(type==""){
return false;
}
$.ajax({
url: "<?=site_url('controller/function')?>"+'/'+type,
success: function(data){
}
});
}
它总是在我的firebug控制台中给我一个红线错误,并打破了我的所有功能,
uncaught syntaxerror unexpected token=
我想知道,为什么它给了我一个错误,虽然每个东西都完全在firefox中工作,我正在使用以下jquery库,
<script src="path/jquery-1.7.1.js"></script>
<script src="path/jquery-ui-1.8.16.min.js"></script>
修改
这里我称之为
<input name="my_type" onblur="is_valid($(this).val());" type="text" class="required />
答案 0 :(得分:2)
方法签名无效,您无法应用默认值
一种可能的解决方案是检查该值是否为假值,它将返回类型为undefined
,''
,0
,NULL等的值
function is_valid(type) {
if(!type){
return false;
}
$.ajax({
url: "<?=site_url('controller/function')?>"+'/'+type,
success: function(data){
}
});
}
答案 1 :(得分:1)
可能有一些characters
可以说zero-space characters
不是shown
,尝试删除代码并再次输入可能会解决您的问题。
同时更改您的function is_valid
赞,
function is_valid(type) {// remove assignment of type from here
if(typeof(type)==='undefined' || !type){
return false;
}
... remaining code