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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:13:39+00:00 2026-05-23T18:13:39+00:00

I am using jquery form plugin for file upload . my question is how

  • 0

I am using jquery form plugin for file upload . my question is how to access the jsonresult from the controller in the script part of view using jquery.
my script is as

 $(function() {
       $("#uploadForm").ajaxForm({
               iframe: true,
               dataType: "json",
               contentType: "application/json; charset=utf-8",
                target :"myTable",
               url: "/UploadFile/Index",
             success: function(response,statusText)  {
        var jsonObject= result.childNodes[0].innerHTML;
       for (i = 0; i < response.length; i++) {
               alert(response.filesList[i]);
                   $('#myTable').append('<tr><td> <a href=' + response.filesList[i] + '></a> td></tr>');
               }
        }
    }
      })
 })

and in my controller takes filename and adds to static list type string filesList and returns as jsonresult type

 [AcceptVerbs(HttpVerbs.Post)]
            public JsonResult Index(HttpPostedFileBase file)
            {
    string filename = file.FileName;
                filesList.Add(filename);
   return new JsonResult
        { ContentType = "text/plain",
            Data = Json(new
                {
                 filesList = filesList.Select(x => "File uploaded successfully " + x)
                }, JsonRequestBehavior.AllowGet)
        };
}

But i think it is wrong representation of handling json result in script, what i want it to do is append filesList to table ,for that how to handle jsonresult object in script.

thanking you,
michaeld

  • 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-23T18:13:40+00:00Added an answer on May 23, 2026 at 6:13 pm

    If i understood your problem, first you should rewrite controller. Why would you need text/html when returning json? And string + list of strings is impossible, i guess you want the list of the messages and file names

        [AcceptVerbs(HttpVerbs.Post)]
    public JsonResult Index(HttpPostedFileBase file)
                {
                    List<String> fileNames = new List<string>();
    
                fileNames.Add(file.FileName);
    
    
                return Json(new
                {
                    FileNames = fileNames.Select(x=> "File uploaded successfully " + x)
                }, JsonRequestBehavior.AllowGet);
    }
    

    Then on client side, directly use the result object, as you set the dataType = ‘json’, it is already the json object

    success: function(result) {
           for (i = 0; i < result.FileNames; i++) {
           $('#myTable').append('<tr><td> <a href=' + result.FileNames[i] + '></a> td></tr>');
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have file upload using jquery form plugin as $(function() { $(#Form).ajaxForm({ iframe: true,
i am using jquery form plugin for file upload . i am not able
I'm using the jquery form plugin ( http://malsup.com/jquery/form/ ) to upload a file via
I'm using the jQuery plugin ajaxForm to submit a file upload form via AJAX.
I'm using the jquery tokeninput plugin from loopj.com Here is my JS File: $(document).ready(function()
I've got a simple HTML file upload form. I'm using the jQuery validation plugin
I'm using the jQuery Form plugin to upload an image. I've assigned a fade
I am using the multi-upload plugin found at: http://www.fyneworks.com/jquery/multiple-file-upload/ This is what I am
I'm using jQuery form plugin to upload files. The plugin uses a hidden iframe
I'm using a great jQuery contact form validator from bassistance (http://bassistance.de/jquery-plugins/jquery-plugin-validation/) is exactly 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.