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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:58:32+00:00 2026-06-07T04:58:32+00:00

I would like to send an image using AJAX to an .Net MVC server

  • 0

I would like to send an image using AJAX to an .Net MVC server application, and one of the ways I found to do it is using jquery.form.js.
But I am not able to do it, it says that the request can’t be serialized, when I uncomment the part:

// the image I would like to pass
//thumb: $('#imagePath')[0], 

The HTML generated by the CSHTML file is as follows:

HTML generated from CreateItem.cshtml

<div class="ui-dialog ui-widget ui-widget-content ui-corner-all" style="display: block;
z-index: 1002; outline: 0px none; height: auto; width: 557.6px; top: 62px; left: 280px;" tabindex="-1" role="dialog" aria-labelledby="ui-dialog-title-dialog-form">
<div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix">
    <div id="dialog-form" class="ui-dialog-content ui-widget-content" shape-id="3" style="width: auto;
        min-height: 0px; height: 296px;" scrolltop="0" scrollleft="0">
        <form class="item-form" method="post" action="/OrchardLocal/Course/CreateCourse"
        shape-id="3">
        <fieldset shape-id="3">
            <ul class="image-preview-list" shape-id="3">
                <li shape-id="3">
                    <div style="border-color: Black; border-width: thick;" shape-id="3">
                        <img id="thumb" class="image-from-popup" alt="some image" src="/OrchardLocal/Media/Default/Images/abc/abc.jpg"
                            shape-id="3">
                    </div>
                </li>
                <li shape-id="3">
            </ul>
            <label for="description" shape-id="3">
                Description</label>
            <textarea id="description" class="description-text text ui-widget-content ui-corner-all description-class"
                rows="2" name="description" cols="20" shape-id="3"></textarea>
        </fieldset>
        <input type="hidden" value="FApn3HBCkLLIo59k6ZFvlT4/Ug+3ZDhILay4C+hbdG7lAQfeWyms5ulVZ2scLkHgmwkqhDk0121dT03116VIVrSmWr3Tp0njksqX/Gnr3BK1nI7GdO1Em6ugdAbBJcUSNP0snS1DOHffG7sbq8x/dyK/ALI1bY+HDdIkk2oW5oC63YkV7Fq5pc7MjkPjTEj9o8oCYSFBsm0OdCzsZlpWFw=="
            name="__RequestVerificationToken" shape-id="3">
        </form>
    </div>
    <div class="ui-dialog-buttonpane ui-widget-content ui-helper-clearfix">
        <div class="ui-dialog-buttonset">
            <button type="button">
                Create</button>
        </div>
    </div>
</div>

I have a javaScript file that:

$(document).ready(function () {
    // bind '.item-form' and provide a simple callback function 
    $('.item-form').ajaxForm(function () {

        alert("Thank you for your comment!");
    });
}); 

$(function () {


    var UNIQUE_TITLE = "You must specify an unique title";
    var TITLE_IS_REQUIRED = "You must specify a title";
    var DESCRIPTION_IS_REQUIRED = "You must specify a description";




    $('#dialog-form').dialog({
        autoOpen: false,
        height: 400.6,
        width: 557.6,
        modal: true,
        draggable: false,
        resizable: false,
        buttons: {
            "Create": function () {

                var newContactItem = {
                    title: $.trim($("#title").val()),
                    description: $.trim($(".description-class").val()),
                    imagePath: $.trim($("#imagePath").val()),


                    // the image I would like to pass
                    //thumb: $('#imagePath')[0], 


                    __RequestVerificationToken: antiForgeryToken                    }


                var form = $('.item-form');

                $.ajax({
                    type: "POST",
                    url: form.attr("action"), 
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    data: JSON.stringify(newContactItem),
                    success: function (data) {
                        // There is no problem with the validation
                        if (data.valid) {
                            $('#eventos').html(html);
                        }

                      $.each(data.Errors, function (key, value) {
                            if (value != null) {
                                $("#Err_" + key).html(value[value.length - 1].ErrorMessage);
                            }
                        });

                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        alert(XMLHttpRequest.responseText);
                        alert("Critical Error!. Failed to call the server.");
                    }
                });


            }
        }
    });
  • 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-07T04:58:34+00:00Added an answer on June 7, 2026 at 4:58 am

    You cannot use both ajaxForm and jQuery.post to send the form. I believe you will need to rewrite, using only ajaxForm.

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

Sidebar

Related Questions

I'm using a Rails application and would like to send/receive text messages through my
I would like to send and receive OpenSoundControl in an AIR application, on the
I would like to send a struct from my client program to a server
I am using jQuery/FLOT to draw a graph, I would like for the user
I am using express and I would like to serve a generated image. The
I would like to send POST message using bash script.In body there should be
I would like to send/recieve image files and 2 ints as messages in a
I am using the following code to send email in codeigniter and would like
I would like to send a .gif file over a serial port connection using
Found this technique of using ajax to preload things at: http://perishablepress.com/3-ways-preload-images-css-javascript-ajax/ window.onload = function()

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.