Help with remote JSON call.

Help with remote JSON call.

I have a little notification script I'm working on and am having a little trouble getting the getJSON() function to work properly. Here is the code I'm using:

<script type="text/javascript">
    var auto_refresh = setInterval(function () {
        var lastid=$("#lastid").val();
        $.getJSON("http://remoteurl.tld/file.php?lastid="+lastid",function(data) {
            $.each(data.alerts, function(i,mydata) {
                if (lastid != mydata.id) {
                    $.pnotify({
                        pnotify_text: \'"+mydata.msg+"\',
                        pnotify_addclass: \'custom\',
                        pnotify_nonblock: false,
                        pnotify_nonblock_opacity: .2,
                        pnotify_closer: true
                    });
                    var updated_lastid = mydata.id;
                    $("#lastid").val(updated_lastid);
                }
            });
        });
    }, 2000);
</script>
<input type="hidden" id="lastid" value="" />


If I request the PHP file that outputs JSON manually, here is the format:


{"alerts": [
{ "id":"82", "msg":"2010-09-01 11:12:09: Too many messages in queue on fsdgfsdgsdfgsfdgfsdg - Current count: 1276" }, { "id":"81", "msg":"2010-09-01 11:12:06: Processor load high on gfhjgfhjgfhjgfhjgfhj - Current load: 12.97" }, ]} It all appears to be valid.. But when I open the page in firefox+firebug, the .each statement is returning "data is null" Anyone have an idea where the problem might be? Thanks