0

I am developing my first website. At this time i am generating a new html design that would be a ticket. From my main page, i will load this html when the user clicks the "See ticket" button. This html has a table which is filled on document.ready with javascript. The data used is a JSON created in the main page.

I coded a working solution using localStorage. The problem is that the next step is to convert that HTML website to PDF and the software i am using does not work properly with localStorage, so i need to pass the JSON from main page to the ticket page. I can't neither use URL encoding cause string could be sometimes longer than 2000 characters and it is not productive.

So i thought that maybe i could do and $.get call from the ticket.html to index.html and get the needed JSON. Is this approach correct, or is there any better solution?

Regards

4
  • question is quite confusing since JSON is rarely delivered from .html file extension and is more commonly sent from extension associated to whatever server side language your server runs Commented Oct 11, 2014 at 13:08
  • well, i capture it using javascript associated to the html, which it does deal perfect with JSONs.. Commented Oct 11, 2014 at 13:14
  • the point is you probably need to post your data to a server script which can be done using $.ajax Commented Oct 11, 2014 at 13:18
  • in that case i would need to store that JSON in a database and then $.get it from ticket.html..isn't there an easier solution to pass this JSON between clientside htmls/javascripts? Commented Oct 11, 2014 at 13:24

1 Answer 1

1

As suggested earlier comments, you need to use serverside code to accept post params and you need to do a ajax post to send the data. This is very good approach. I have one more idea for implementing this.

Let say you open ticket.html in a window.open. And have a JS function ( say GetValue) in index.html, that returns JSON . So you need to get JSON in ticket.html.

You need to define a JS function in ticket.html , using windown.opener.GetValue() , you can get JSON value.

Hope, i am in same direction, which you need. If not, please clarify.

Other way, would be use iFrame and use message communication to pass large data between them, you are interested in this, please read this - https://developer.mozilla.org/en-US/docs/Web/API/Window.postMessage

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks.i'll try this later on and i'll tell you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.