Reputation: 9364
What the hell wrong with this function in google chrome, while it is working absolutely perfect in firefox,
function is_valid(type="") {
if(type==""){
return false;
}
$.ajax({
url: "<?=site_url('controller/function')?>"+'/'+type,
success: function(data){
}
});
}
it always gives me a red line error in my firebug console, and breaks all my functionality,
uncaught syntaxerror unexpected token=
I am wondering that, why it is giving me an error, while every thing is perfectly working in firefox, i am using following jquery libraries,
<script src="path/jquery-1.7.1.js"></script>
<script src="path/jquery-ui-1.8.16.min.js"></script>
EDIT
here i call this,
<input name="my_type" onblur="is_valid($(this).val());" type="text" class="required />
Upvotes: 0
Views: 975
Reputation: 40639
There may be some characters
can say zero-space characters
which are not shown
, try to delete the code and type again may solve your problem.
Also change your function is_valid
like,
function is_valid(type) {// remove assignment of type from here
if(typeof(type)==='undefined' || !type){
return false;
}
... remaining code
Upvotes: 1
Reputation: 388316
The method signature is invalid, you can't apply a default value like that
One possible solution is to check whether the value is a falsy value like, it will return of the value of type is undefined
, ''
, 0
, NULL, etc
function is_valid(type) {
if(!type){
return false;
}
$.ajax({
url: "<?=site_url('controller/function')?>"+'/'+type,
success: function(data){
}
});
}
Upvotes: 2