0

I'm trying to update my HTML UI with data returned from a server running on an embedded system (means I have full control over what is returned). The data callback in the .ajax function never seems to be called however, why would this be?

The jQuery code is


$(document).ready(function() {
    $('#pollGps').click(function() {
        alert('calling /pollgps.json'); 
        $.ajax({
            url: '/pollgps.json',
            dataType:'json',
            success: function( data ) {
                alert('success ' + JSON.stringify(data));
                $("#settingId").html(data.settingId);
                $("#settingValue").html(data.settingValue);
            }
            error: function(jqXHR, textStatus, errorThrown) {
                alert('Error polling GPS ' + textStatus);
            }
        });
    });
})

and the server response is

HTTP/1.0 200 OK
Content-Type: application/json

{
"settingId"="CFG-NAV2",
"settingValue"="0xdead"
}
1
  • Did you try to stringify your data before alerting it or simply logging it to the console to see what's there ? Commented Feb 27, 2012 at 0:44

1 Answer 1

2

This is not valid JSON

{
    "settingId"="CFG-NAV2",
    "settingValue"="0xdead"
}

The following is

{
    "settingId" : "CFG-NAV2",
    "settingValue" : "0xdead"
}

Get familiar with JSONLint.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, am generating the JSON by hand so a little error prone. Got it working now.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.