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 6639221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:31:43+00:00 2026-05-25T23:31:43+00:00

Is it possible to use the JQuery ajax method to pass parameters into a

  • 0

Is it possible to use the JQuery ajax method to pass parameters into a controller, have the action in the controller return an image and display that image back to the user?

$.ajax({
    type: 'POST',
    url: '/Controller/Action',
    data: { 'parameter1': '\'' + parameter1Value + '\'', 'parameter2': '\'' + parameter1Value + '\'', 'parameter3': '\'' + parameter1Value },
    dataType: 'image' /* Can ajax return an image? */,
    success: function (imageResults) {
        // Do something
    },
    error: function (xhr, status, error) {
        // Do something else
    }
}

My goal is to generate a dynamic image based on parameters in the form and display that image back to the user. In addtion, ad added bonus would be to fire the ajaxstart and ajaxstop handling used by other ajax calls on the page.

  • 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-05-25T23:31:43+00:00Added an answer on May 25, 2026 at 11:31 pm

    Don’t AJAX controller actions that return images or files or something. A much easier solution is the following:

    $('body').append(
        $('<img/>', {
            src: '@Url.Action("Action", "Controller")?parameter1=' + encodeURIComponent(parameter1Value) + '&parameter2=' + encodeURIComponent(parameter2Value),
            alt: 'some image'
        })
    );
    

    This simply dynamically injects the following <img> tag to the end of the <body> (you could of course adapt the location if you don’t like the body):

    <img src="/Controller/Action/?parameter1=foo&parameter2=bar" alt="some image" />
    

    The browser will do the rest. Just ensure that the controller action returns a File result.

    Also if those images are dynamically generated each time, IE could cause certain PITAs as it might cache them. To bust the cache append a random timestamp to the url:

    $('body').append(
        $('<img/>', {
            src: '@Url.Action("Action", "Controller")?parameter1=' + encodeURIComponent(parameter1Value) + '&parameter2=' + encodeURIComponent(parameter2Value) + '&cacheBuster=' + encodeURIComponent((new Date()).getTime()),
            alt: 'some image'
        })
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to use a jQuery ajax call to perform Forms Authentication with
I have recently started looking into Google Charts API for possible use within the
Is it possible to use a custom HTTP VERB, like MERGE, with jQuery.ajax()? I'm
I have a page with a menu that uses JQuery AJAX calls to populate
is it possible to use jquery ajax to send GET variables to Solr and
I was wondering if it would be possible to use jQuery's ajax function to
Is it possible to use jquery .ajax() call to post a file to the
I have some problem with my form. i want to use jquery ajax to
Is it possible to use jQuery.ajax() in node.js exactly as it is syntax-wise? I
I know it is possible to use jQuery to do something like: $('body').css('cursor','wait'); What

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.