/    Sign up×
Community /Pin to ProfileBookmark

I am trying to write JSON stuff in php to send it to javascript to make an ajax website but am having no luck and for some reason there are very very few examples on the internet. It seems like a good way to do things but I just wish the idiots would write some simple guides on how to use it.

Anyways here is my problem:
I am trying to output the following:
echo ‘{“data”:”{[“matches_num”:”$matches_num”]}, {[“players_num”: “$players_num”]},”.json_encode($data_array).”}’;

The above is two variables plus an object array however it is not working in the javascript that it is sent to. It gives this error:
Error: missing } after property list
Source Code:
({“data”:”{[“matches_num”:”$matches_num”]}, {[“players_num”: “$players_num”]},”.json_encode($data_array).”})

I am using eval() to get it in javascript.

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @Petty_Crim spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...