I found this code from Facebook. I would like to use a structure in this way. How can I use this method?
for (;;);{"__ar":1,"payload":null,"css":["wOyD6","Dk+z9","uUZcv"],"js":["TNp9j","12BHN"],"onload":["(function(){var k=Arbiter.subscribe(\"xhpc\\\/construct\\\/\"+this.id,function(_,c){(function(){Arbiter.unsubscribe(k);}).defer();c.mutate({\"xhpc\":\"u598502_6\",\"endpoint\":\"\\\/ajax\\\/questions\\\/save.php\",\"formType\":1,\"inputHidden\":true,\"placeholder\":\"Bir \\u015fey sor...\",\"buttonLabel\":\"Payla\\u015f\",\"blurb\":\"\\u003ca class=\\\"addPollOptionsLink\\\" rel=\\\"async\\\" ajaxify=\\\"\\\/ajax\\\/questions\\\/show_poll_composer.php?xhpc_ismeta=true\\\">Anket \\u015e\\u0131klar\\u0131 Ekle\\u003c\\\/a>\",\"content\":\"\\u003cdiv class=\\\"webComposerQuestion\\\">\\u003cinput type=\\\"hidden\\\" autocomplete=\\\"off\\\" name=\\\"source\\\" value=\\\"composer\\\" \\\/>\\u003cdiv class=\\\"mas\\\">\\u003ctextarea class=\\\"DOMControl_placeholder uiTextareaNoResize uiTextareaAutogrow questionInput fluidInput\\\" title=\\\"Bir \\u015fey sor...\\\" spellcheck=\\\"true\\\" name=\\\"question\\\" maxlength=\\\"500\\\" placeholder=\\\"Bir \\u015fey sor...\\\" id=\\\"u614163_1\\\" onfocus=\\\"return wait_for_load(this, event, function() {if (!this._has_control) { new TextAreaControl(this).setAutogrow(true); this._h开发者_JS百科as_control = true; } });\\\">Bir \\u015fey sor...\\u003c\\\/textarea>\\u003c\\\/div>\\u003c\\\/div>\",\"hideTopicTagger\":true});c.subscribe(\"init\", new Function(\"onloadRegister(function (){Input.enableAutoCapitalize($(\\\"u614163_1\\\"), \\\"\\\");});\\n\"));});;}).apply(DOM.find(this.getRelativeTo(),\"^div.uiComposer\"))"],"bootloadable":{"maxlength-form-listener":["LayX0","nO1QQ","12BHN"]},"resource_map":{"wOyD6":{"type":"css","src":"https:\/\/s-static.ak.facebook.com\/rsrc.php\/v1\/yC\/r\/Zg0ARUxUS6N.css"},"Dk+z9":{"type":"css","src":"https:\/\/s-static.ak.facebook.com\/rsrc.php\/v1\/yw\/r\/q4nJ2ZkJtyT.css"},"uUZcv":{"type":"css","permanent":1,"src":"https:\/\/s-static.ak.facebook.com\/rsrc.php\/v1\/yO\/r\/4okS7_KFNGX.css"},"TNp9j":{"type":"js","src":"https:\/\/s-static.ak.facebook.com\/rsrc.php\/v1\/yo\/r\/8rrAXwg5z80.js"},"12BHN":{"type":"js","src":"https:\/\/s-static.ak.facebook.com\/rsrc.php\/v1\/yg\/r\/jkR6Xtb9PGX.js"},"LayX0":{"type":"js","src":"https:\/\/s-static.ak.facebook.com\/rsrc.php\/v1\/yn\/r\/HT0e0kw4zvt.js"},"nO1QQ":{"type":"js","src":"https:\/\/s-static.ak.facebook.com\/rsrc.php\/v1\/y8\/r\/Cu4Eol99gUR.js"}}}
It's not clear what exactly you are asking. You can't "run" this code, it's a JSON string. If you want to access the data, you'll need to parse it some way, for example parseJSON in jquery.
I suspect you may be getting tripped up by the leading for (;;);
string. This is a protective device put there to keep people from simply using eval()
to process the data. Using eval()
is an old quick-and-dirty way to parse JSON directly into javascript variables, but it's an unsafe practice. To prevent it Facebook adds the for-loop code to the front of the string, so that if you try to eval it you just get an infinite loop and a hung browser. You could of course strip that part off of the string and then use eval anyway, but you're much better off parsing it properly.
精彩评论