Patrioticcow
Patrioticcow

Reputation: 27058

Loading 2 or mode jSon files problem in Jquery?

i am trying to load some data using json and jquery the problem occurs when i call data from 2 files like this:

$.getJSON('json/profile.json', function(data) { 
$('#online').html(data.todo );
});

$.getJSON('json/character.json', function(data) {   
$('#offline').html(data.fname + " " + data.lname );
});

if i use only one file it works, but with both doesnt. Wired.

any ideas?

thanks

edit: i have them like this: i have an index.php and file1.php and file2.php .

each file1 and file2 are included in the index.php and each file1.php and file2.php call a json file.

Upvotes: 1

Views: 182

Answers (1)

karim79
karim79

Reputation: 342745

I bet you execute them in that sequence every time. The first one works because the JSON is well-formed, the second one fails because the JSON is malformed. $.getJSON will fail silently if it gets bad JSON from the server.

Upvotes: 0

Related Questions