javascript - Json not able to access via dot operator -


i using a4j jsfunction send data server , receive json server

<a4j:jsfunction name="submitdata" action="#{imageretrivebean.savedata}" data="#{responsenodespathsbean}" oncomplete="processdata(event.data)">     <a4j:param name="param1" noescape="true" value="myfunction()"     assignto="#{imageretrivebean.requestjsonmsg}" />     <a4j:param name="param2" noescape="true" value="getfloorno()"     assignto="#{imageretrivebean.floorno}" /> </a4j:jsfunction> 

in processdata function below

function processdata(data) {     console.log(data);     var dataobj = data.responsejsonmsg; } 

the console.log prints data correctly. following output.

({responsejsonmsg:"{//my data}"}) 

but not able access data using data.responsejsonmsg

the console gives error

typeerror: data undefined 

images of code error occurs , error output on chrome

https://docs.google.com/file/d/0b2lrastq7rleouthmtrft2sxams/edit?usp=sharing

https://docs.google.com/file/d/0b2lrastq7rleu09vdll1vurat2c/edit?usp=sharing

please me know wrong. thanks

if output of console.log, not javascript object, need parse json.parse(data), though showing not valid json string anyway still error out. need parenthesis removed, responsejsonmsg need quoted etc. need have server side code output valid json string

it should like, if //my data supposed actual data

{"responsejsonmsg":{ "name":"patrick", "where":"here" }}


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -