For the sake of some older browsers, you'll need to wrap class
in quotation marks.
data:{"class":"image",...
While ECMAScript allows reserved words as property identifiers, some older browsers didn't allow it.
Question
I have a weird bug in internet explorer 7 and 8 when I am using javascript object. It work in IE9 and all the others.
When I am using an object and any of my parameter in the object is "class" internet explorer 7 and 8 stop doing anything.
I am using jquery 1.8.2.
I'll show you some code.
var obj = {
data:{class:'image',action:'getAllFkId',type:nbType, fkid:id},
success:function(json){
alert('hi');
}
};
this.ajax(obj);
Code of "this.ajax" (the "this" is an object) :
ajax : function(params){
var defaults = {
url: '../index.php',
type:'POST',
data:{},
dataType:'json',
success:function(){/*Function handler*/}
}
var options = $.extend(defaults, params);
$.ajax(options);
return this;
}, // ..... rest of code
If I change the name of the parameter to anything else it works.
// This is just fine foo instead of class
var obj = {
data:{foo:'image',action:'getAllFkId',type:nbType, fkid:id},
success:function(json){
alert('hi');
}
};
this.ajax(obj);
I would like to understand why IE7-8 won't work with "class" as a parameter. Thanks for your time.
Solution
For the sake of some older browsers, you'll need to wrap class
in quotation marks.
data:{"class":"image",...
While ECMAScript allows reserved words as property identifiers, some older browsers didn't allow it.