javascript - Encode html elements to JSON in php -
im trying encode next string in php can sent json object:
success:{'id':'success=-message', 'class':'success-message', 'inner-html':'congratulations! have been succesfully logged in'}, logout: {'type'='button', 'value'='logout', 'class'='logout-button'}, sessionid: {'type'='hidden', 'name'='sessionid', 'value'=1}
how can format can encoded using json_encode()?
{'success':{'id':'success=-message', 'class':'success-message', 'inner-html':'congratulations! have been succesfully logged in'}, 'logout': {'type'='button', 'value'='logout', 'class'='logout-button'}, 'sessionid': {'type'='hidden', 'name'='sessionid', 'value'=1}}
you need curly brackets (begin & end) create valid json array.
and keys need quoted.
javascript php html json
No comments:
Post a Comment