I have the below requirement.
I have a data grid, which has huge amount of data. I have a download button, when clicked data grid data has to be downloaded to an excel. This data grid data I want to send to server through a rest call using xhrpost. With this data i will construct an excel file on the fly on server side and i will return the response to the client. My client by seeing this response should open popup for downloading the response to save as the file.
I am seeing the following problems here :
the data is huge. so , I can't use window.open way for sending the data in GET format.
I don't have an URL on server which will access file, as i am generating file on the fly and sending response to client.
How will i achieve my use case to download file using xhrpost on the fly, not storing the file anywhere?
Please reply as I am breaking my head how to do this? It will be of great help.
Thanks,
Sreenivas
Related
$.getJSON let us to get data from the file, is there any way to set data into the file? i have tried $.setJSON, but it shows me "$.setJSON is not a function".
You can't access the local file system using front-end Javascript. And there is no way on doing it.
What you can do is create a web server.
Send a request with the data in the server using AJAX
On the server, save the data by writing it on a file
That's pretty much it.
I am working on a nodejs service where I need to read a PDF document from a file.
At a high level, here is the workflow. First time a user requests a PDF, I generate it (using pdfkitjs) and save it to the server. Then, when the user request the same document again, I need to read it from the server and send it back.
Is there a way that I can use PDFDocument from pdfkitjs to read the contents from the file and create a corresponding PDFDocument? Almost all searches come up with how to pipe the PDF to a stream, but now how to read from a stream.
If "the stream" is your server response then you shouldn't have to do much more than add the appropriate headers to the response first.
I am pulling a JSON file from a server within my app. When my app deals with this data, I need to write some changes to this JSON file and upload back to the original source.
So if I wanted to edit and write the data in Category in the data below to "Full Stack", how could this be done? I then need to upload to the server to update at their end.
https://gist.githubusercontent.com/planetoftheweb/4069235/raw/0ca9457d10f9ff0be578a699954910d7d6626726/sampledata.json
Currently I have a working javascript/jquery file that makes a request to a php file to retrieve json data. This works great.
Some information is taken from the server and send back to the javascript/jquery.
So:
Request from js to exchange.php ==>
exchange.php access database and gets certain data
<=== response from exchange.php to jquery to send data to js
js uses data to make some changes to the website (changes phonenumber)
This has to be done as fast as possible. But after I have send the data to the js I want the same exchange.php log this data + some userdata to another database. For speed reasons I want to do this after the data is sent to the javascript. Is this possible?
Currently I just call the logging class after I echo'd json_encode(); But does it make a difference? Or will the json be send only after the whole php file has finished running?
I'm posting json to my server and I want to return a csv response and have my browser automatically download the csv.
I know there have been some questions on SO exactly about this topic on the past. So far, I've gathered the following solutions:
Put the request into <form> element. This isn't possible because the JSON is nested and too large to be posted as a string.
Save the csv file (get request) onto the server and then have a separate post request to download it. This is not ideal because I don't want to keep a bunch of useless csv files on my server.
Is there a better solution? Can I make a Post request act like a form submission and automatically get the file to start downloading?