I have following code for reading a JSON file.It is giving no error but i am getting null in the variable:
var myData = null;
$.ajax({
type: 'GET',
async: false,
url: 'myJson.json',
dataType: 'json',
success: function (r) {
myData = r;
}
});
Below is my JSON file:
{items:[{value:"1",name:"John"},{value:"2",name:"Henry"}]};
$.getJSON
instead? – Marty May 23 '13 at 5:05async : true
.. ajax call should be asynchronous always. and your json is wrong as mentioned by benjamin in below post. Try jsonLint to test whether your json is in correct format or not, always. – Mr_Green May 23 '13 at 5:27