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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:10:21+00:00 2026-05-26T03:10:21+00:00

I am having problems with an Ajax/jQuery postback in ASP.NET MVC 3. If validation

  • 0

I am having problems with an Ajax/jQuery postback in ASP.NET MVC 3.

  • If validation fails on the code below, the expected result is given and the form does not post.
  • If validation succeeds, the function below is not hit upon form submission and the form submits and returns a json file to the browser.

If anybody could shed some light on this, I’d appreciate it.

I’ve included my partial, view and controller below.

My View

@model TheLayer.EF.NoteAddPartial

@{using (Html.BeginForm("Create", "Note", new { area = "" }, FormMethod.Post, new { id = "noteAdd" }))
{ 

@Html.TextAreaFor(m => m.Note_Text, new { @class = "note-input"  })  //note-input
@Html.ValidationMessageFor(model => model.Note_Text)     

<input type="submit" value="Send" /> 

}}

My client side script (within the view)

<script type="text/javascript">

$(function () {

    $('#noteAdd').submit(function (e) {

        e.preventDefault();

        if ($(this).valid()) {
            alert('posting');
            $.ajax({
                url: this.action,
                type: this.method,
                data: $(this).serialize(),
                error: function (xhr, ajaxOptions, thrownError) {
                    alert('An error occured when processing this request:\r\n\r\n' + thrownError);
                },
                success: function (result) {
                    alert(result.s);
                }
            });
        }
        return false;
    });
});

My Controller

public class NoteController : Controller
{
    [AcceptVerbs(HttpVerbs.Post)]
    public JsonResult Create(NoteAddPartial model)
    {
        try
        {
            NoteMethods.CreateLeadNote(model.Note_Text, SessionManager.Current.ActiveUser.Username, model.ItemId, SessionManager.Current.ActiveUser.Company);
            return Json(new { s = "Success" });
        }
        catch (NoPermissionException)
        {
            return Json(new { s = "No permission" }); 
        }

    }
}

My Partial

namespace XX
{
/// <summary>
/// Partial lead person view
/// </summary>
[MetadataType(typeof(NoteAddPartial_Validation))]
public partial class NoteAddPartial
{
    public string Note_Text { get; set; }
    public int? Source { get; set; }
    public string Username { get; set; }
    public int ItemId { get; set; }
    public int TypeId { get; set; }

}
public class NoteAddPartial_Validation
{

    [Required]
    public string Note_Text { get; set; }

    [HiddenInput(DisplayValue = false)]
    public int ItemId { get; set; }

    [HiddenInput(DisplayValue = false)]
    public int TypeId { get; set; }

}
}
  • 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-26T03:10:21+00:00Added an answer on May 26, 2026 at 3:10 am

    did you add client side validation libraries?

    jquery.validate.min.js

    jquery.validate.unobtrusive.min.js

    NOTE :

    If you configured you app not to work with unobtrusive validation, you
    do not need to reference the second library.

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

Sidebar

Related Questions

I am having problems with jQuery Ajax and PHP I have my php file
I'm working in Jquery Mobile and I'm having problems refreshing the listview after Ajax
I am using asp.net MVC to develop an application that will have ajax interactions.
I'm having problems using ajax with jQuery... I have the following jscript: $(document).ready(function() {
Having problems with my ASP.NET MVC2 project. I'm using Fluent NHibernate as ORM, and
I'm having problems passing a strongly typed object to WCF service via Jquery Ajax.
I have my jquery ajax tabs running great. However I having problems getting/setting the
I'm having some big problems with encoding in Firefox when using AJAX and jQuery.
I am having a couple of problems involving PHP & AJAX using jQuery. To
I'm having some problems with a jQuery form submission. Here is my jQuery code;

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.