Issue retrieving JSON results from php

Issue retrieving JSON results from php

Hi guys hoping someone can help me here,

When running the following query I'm receiving the JS error  Uncaught TypeError: Cannot read property 'ID' of null.

  1. $.getJSON(
  2. 'query/query.php',
  3. { 'task':'course_view' },
  4.     function( data )
  5. {
  6.       alert("Data Loaded: " + data.ID);
  7.     }
  8. );

However when I replace the $.getJSON( with $('#content').load( I quite happily see the following JSON formatted data on my page:

{"ID":"1","Name":"Test","NumberOfYears":"6"}

Any ideas why getJSON doesn't appear to be picking this up?

Many thanks