I have a web page which I want to send some JSON data down with. Currently, I put necessary information within hidden input tags, then I make a call to a webservice to retrieve extra data. I would like to know what ways are available to merge the calls together.
Share
Not sure what you mean about merging the calls together, but I don’t see any reason for putting JSON data in hidden form fields. I’d just put it in a
scripttag as a JavaScript literal:Since JSON is a subset of JavaScript object literal syntax, you can safely assume valid JSON is a valid JavaScript object literal.
For example, if your JSON is:
Then this is what the
scripttag would look like: