Skip to content

Instantly share code, notes, and snippets.

@robotlolita
Created January 12, 2011 20:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robotlolita/776822 to your computer and use it in GitHub Desktop.
Save robotlolita/776822 to your computer and use it in GitHub Desktop.
Página 1:
<form id="frmData" method="GET">
<input type="hidden" id="post-data" name="data" value="">
</form>
<script type="text/javascript">
document.getElementById("post-data").value = JSON.stringify([1,2,3])
</script>
Página 2:
<script type="text/javascript">
var query, querylist, i, pair, jsdata
query = {}
querylist = window.location.search.slice(1).split("&")
for (i = 0; i < querylist.length; ++i) {
pair = querylist[i].split("=", 2)
query[pair[0]] = pair[1] }
jsdata = JSON.parse(query["data"])
</script>
Página 2 (usando server side):
<script type="text/javascript">
var jsdata = JSON.parse(<!-- insira a string com os dados passados aqui, com a linguagem server-side que você está usando -->)
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment