samuk
samuk

Reputation: 167

Ajax call for JSON data works with FF, but not with other browsers

I have done a php page which returns a (valid) JSON document. The jQuery code is very simple:

$.ajax({
   url: "http://localhost:8888/rkm/json-jc",
   dataType: "json",
   success: function(data) {
     console.log(data);
     $('li.jcarousel-item-1', context).html(
       '<img src="' + data.nodes['0'].node.vignette + '">'
     );
   }
});

It works fine in FF and the object returned is OK => see 'FF_console' attached. But... it doesn't work in Chrome, Safari and Opera, without throwing errors. The data 'vignette' returned is just undefined => see 'Chrome_console' attached. Thanks in advance for your help !

NB: jQuery version is 1.3.6 Chrome iimage FF image

Upvotes: 1

Views: 166

Answers (2)

Sameera Thilakasiri
Sameera Thilakasiri

Reputation: 9508

 '<img src="' + data.nodes['0'].node.vignette + '">'

Should probably be

 '<img src="' + data.nodes[0].node.vignette + '">'

In addition to

 console.log(data);

It would be helpful to see

 console.log(JSON.stringify(data));

Upvotes: 1

Jai
Jai

Reputation: 74748

I would suggest u to use latest jquery version 1.7+

http://code.jquery.com/jquery-1.8.2.js

Upvotes: 1

Related Questions