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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:58:48+00:00 2026-06-05T17:58:48+00:00

Im including the popular file jquery.form.js. I have the following: var options = {

  • 0

Im including the popular file jquery.form.js. I have the following:

 var options = {
    beforeSubmit: beforeSubmit,  // pre-submit callback 
    success: afterSubmit  // post-submit callback 
  };

 $('#myForm').submit(function (e) {
     $(this).ajaxSubmit(options);
     return false;
  });


 function afterSubmit(responseText, statusText, xhr, $form) {
   // i want to check for an error
}

I call this action:

    [HttpPost] 
    public string UploadDocument(DocumentModel model)
    {
        if (noerror)
        return "ok";
        else
         return "the error";
    }

Somewhere in the parameters ‘responseText, statusText, xhr, $form’ the return string is stored.

Where is my return string stored, or how do i store it, so i can check the results when the ‘afterSubmit’ javascript function is called? Thanks

  • 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-05T17:58:51+00:00Added an answer on June 5, 2026 at 5:58 pm

    Never return strings from controller actions. In ASP.NET MVC controller actions should return ActionResults:

    [HttpPost] 
    public string UploadDocument(DocumentModel model)
    {
        if (noerror)
            return Content("ok");
        else
            return Content("the error");
    }
    

    and then the result will be stored in the responseText variable.

    Obviously testing in your javascript if (responseText == 'ok') seems like something absolutely horrible and for this reason there’s JSON:

    [HttpPost] 
    public string UploadDocument(DocumentModel model)
    {
        if (noerror)
            return Json(new { success = true });
        else
            return Json(new { success = false });
    }
    

    so that in your javascript you could work directly with the underlying types (boolean in this case):

    function afterSubmit(response, statusText, xhr, $form) {
        if (response.success) {
            alert('super! we succeeded');
        } else {
            alert('Oh snap!');
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a webpage including the following div: <div class='book_box'> <table border=0 cellspacing=0> <tr>
Here's a common practice I see often (including from a very popular iPhone developer
While including the simple HTML DOM library, I get the warnings: Warning: file_get_contents() [function.file-get-contents]:
I'm including the MySQLi connection file in the constructor of a PHP class. Since
I have a web application where I need to keep track of most popular
When including a file in another, I want to end the parsing after a
Since including <mvc:annotation-driven/> I have experienced a problem when binding the selections of multi-select
Including Pre-Compiled Views in an ASP.NET MVC Web Application Reference please see above blog.
When including the header options to copy_object, the headers DO NOT get updated. Headers
While including a php file (eg: include'filename.php';), is it necessary that the source file

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.