How can i make a save file as option in Ajax response?
This response returns files in 3 different formats.
I have to ask User to save file as in thet format.
(Hope i have to open some Save file prompt)
Can anybody tell me?
Thanks

Recommended Answers

All 6 Replies

Quetions:
Where do you want the file to be saved?
Why not ask the user to choose from the 3 formats before sending the request?

Airshow

Quetions:
Where do you want the file to be saved?
Why not ask the user to choose from the 3 formats before sending the request?

Airshow

Thank U.:)
Well user selected the format of file in frontend , then using ajax, i will send request to back end, then from backend , getting that file in user selected format, (line by line).
Instead of tiz, i have to ask user to choose a place for file to save.
For example if one csv file having content of RED,GREEN,BLUE .. i have to ask user to save file as instead of giving that whole line. Now i get response as whole line(RED,GREEN,BLUE)

OK, but you still haven't told me - where do you want the file to be saved - client or server?

Airshow

OK, but you still haven't told me - where do you want the file to be saved - client or server?

Airshow

Have To Store in client location . They only select location.

OK, but you still haven't told me - where do you want the file to be saved - client or server?

Airshow

Have To Store in client location. They only select location.
(save as prompt have to open)

Nithyavelumani,

Browser limitations mean that you can't save data returned as an AJAX response, as a client-side file.

You are forced into returning a file in response to a regular HTTP request. When the file is returned in the right way (correct MIME type set) the browser will display a standard save dialog. In all modern browsers, the web page will remain intact, so there's little difference in practise between this approach and AJAX.

However, you can only return one file, not three. Hence you need to arrange for the user to select one of the three available file types before the request is sent, then compose the request URL accordingly (eg. append the query string ?type=csv ). Your server-side script will need to read type and compose the file accordingly.

Airshow

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.