jquery - Passing large JSON object to another page in a new window. -


i apologize in advance if has been answered. i've googled around few hours now, , still haven't found seems answer exact question.

essentially, have complex/highly styled view displaying user-specific data pulled database. i've captured data json object, attached body page using .data(). i've added button retrieves json object , opens printer friendly page in new window. want able access/manipulate user-specific json object within new window. (this on same domain.)

most of solutions i've seen seem centered around opening new, blank window. don't want that. i've coded layout page, , plan on having javascript/css runs. i've seen solutions involve opening new window , using document.write, great, if there way target specific element on new page. i've tried, example:

x = window.open(url); x.document.write(myjson); 

which put json object on new page, wipes else had in layout.

i've seen solutions suggest stringifying , base64 encoding object. i'm concerned url length restrictions, given potentially gathering lot of data on page before clicking button.

i've seen solutions suggest using html5 local storage. suppose i'll do, if there's no better solution. html5 raises browser compatibility issues, , i'd prefer avoid them if possible.

here's example code:

json object:

{  { "name":"percy pea.", "bio":"percy pea born in pod, , lived there happily." }, { "name":"james cob", "bio":"james cob arrested stalking." } } 

i capture when comes server 'data':

$("body").data( "userdata", data); 

in onclick printer friendly page button, retrieve json object:

var userdata = $("body").data("userdata"); 

so doable? there way open new window, , insert/attach data specific element inside it? or...maybe other way haven't considered.

thanks in advance help, although sure check-mark answer, once it's posted.

you can save json in global variable in parent window , reference in popup window code

https://stackoverflow.com/a/87737/1755374


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -