Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9091205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:33:18+00:00 2026-06-16T22:33:18+00:00

I am sending JSON object through following code.. Controller returning values in CSV format

  • 0

I am sending JSON object through following code.. Controller returning values in CSV format that should be provide promt to open or save as CSV file. I unable to understand that what exactly code should be write in success: function (result)

Link for Export

Html.ActionLink("Export", "", "", null, new { @onclick = "return exportData();"})

function exportData() {

var searchViewModel = getExLogSearchModelData();
var path = getAbsolutePath("ExclusionLog", "ExportData");
$.ajax({
    url: path,
    cache: false,
    contentType: 'application/json; charset=utf-8',
    dataType: 'html',
    type: 'POST',
    data: JSON.stringify(searchViewModel),
    success: function (result) {
    },
    error: function (error) {
        $("#voidcontainer").html("Error");
    }
});

}

Controller ActionResult

    public ActionResult ExportData(ExclusionLogSearchViewModel postSearchViewModel)
    {
        try
        {
            IEnumerable<ExclusionLogViewModel> exclusionLogData = null;
            exclusionLogcData = this._workerService.GetExclusionLogData(postSearchViewModel);

            return CSVFile(exclusionLogMembershipSyncData.GetStream<ExclusionLogViewModel>(), "ExclusionLogTables.Csv");
        }
        catch (Exception ex)
        {
                throw ex;
        }
        return null;
    }

Can you please suggest how to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T22:33:20+00:00Added an answer on June 16, 2026 at 10:33 pm

    I’ve hit the same problem and I didn’t find a way to download file using $.ajax but I found an excellent JavaScript library that provides similar behavior:

    https://github.com/johnculviner/jquery.fileDownload

    You just need to invoke something like this:

    $.fileDownload(path, {
        httpMethod: 'POST',
        data: JSON.stringify(searchViewModel),
        success: function (result) {
        },
        error: function (error) {
            $("#voidcontainer").html("Error");
        }
    });
    

    And remember to create cookie in controller. In src/Common there is suitable action filter that do it for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am sending a JSON object to a HTTP Server by using the following
I have an application that is sending a JSON object (formatted with Prototype) to
I am creating and sending a JSON Object with jQuery, but I cannot figure
I am trying to receive a json object back from php after sending data
Am am successfully parsing and sending JSON values from my client for my server
I'm sending the following JSON string to my server. ( { id = 1;
I'm sending a JSON object of the same class from a servlet to an
I'm sending a JSON object to PHP using jQuery via $.ajax({ url: myURL, type:
I am using play 1.2.5. I am sending a JSON object from a view
I am sending a json object from java to php. I am using gson

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.