How to download a json file using knockout






















But many developers use conventional based approach without manually write a code for every property to be updated. This can be beneficial if the view model have many properties ,nested data structures, because of the simplicity. We can see those in the coming blogs. Share this: Twitter Facebook. Like this: Like Loading Leave a Reply Cancel reply Enter your comment here Fill in your details below or click an icon to log in:. Email required Address never made public. Name required.

Follow Following. Code Blogger. Sign me up. You can convert it to a JSON string suitable for sending to the server using ko. Or, if you just want the plain JavaScript object graph before serialization, use ko. Note that ko. To generate a nicely formatted display for this purpose, you can pass the spaces argument into ko. For example,. In many scenarios, this direct approach is the simplest and most flexible solution. The somewhat simplified body of the table looks like this:.

I want the a tag to become a link to the file typically a. The problem is you can assume the link etc. As you can see, it contains an attachment "foo. My question is the following: When I click the td element, I want to trigger a download prompt to download the file specified in the JSON.

How can I do this? Like Matt Burland said, the problem is on the server side. On the backend, you have to make sure to properly build your response so that the browser understands that you are currently downloading a file.

For example this is a response header that my application has when I trigger a download of a word document:. For the server side, here is the code I have for downloading the document the response header I pasted. For response. FileName you don't have to escape the filename unless you have special characters which is my case since our application manages French documents.

Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. JS Ask Question. Asked 7 years, 4 months ago. Active 7 years, 3 months ago.



0コメント

  • 1000 / 1000