Welcome Guest, Not a member yet? Register   Sign In
Problem with Jquery JSON in IE8
#1

[eluser]Berserk[/eluser]
Hi there, i've got a @#*&@# problem with JSON in IE8 (not tested in other IE version) but it worked fine in Firefox, Chrome and Safari:

this is my function:

Code:
function get_notifications_count() {        
            $count = $this->notifications->get_notification_count($this->user->id);
            if($count->user_notification_count != 0) {
                echo      json_encode(array('status'=>1,'count'=>$count->user_notification_count));
            }else {
                echo json_encode(array('status'=>0,'count'=>'0'));
            }
        }
    }

result :
Code:
{"status":0,"count":"0"}

and Jquery function:
Code:
$.getJSON(BASE_URL+'ajax/get_notifications_count', function(data){        
        if(data.status == 1){
            $('#notificationcount').html(data.count).css('display','block');
        }else{
            $('#notificationcount').html(data.count).css('display','none');
        }      
    });

it worked fine with FF, Chrome, Safari, but in IE8 got a stupd error :

Code:
Webpage error details

Message: 'status' is null or not an object
Line: 804
Char: 9
Code: 0
URI: http://localhost/public/js/base.js

i don't understand why and how to fix this problem. Help me plz.
#2

[eluser]Berserk[/eluser]
sorry, got the same problem with Opera 10
#3

[eluser]n0xie[/eluser]
Did you try to turn status into a string instead of an integer?

If so, what does Firebug say about your returned JSON object?
#4

[eluser]Berserk[/eluser]
i got no problem with FF, and the result from Firebug is

{"status":0,"count":"0"}

but in IE and Opera look like getJSON function didn't work ( i added an alert but didn't see anything, still alert in FF and Safari )
#5

[eluser]xeroblast[/eluser]
does your AJAX has the capability to detect which browser it is using? firefox and IE has different style... FF is using Object while IE is activeX...




Theme © iAndrew 2016 - Forum software by © MyBB