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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:40:59+00:00 2026-06-06T22:40:59+00:00

I am trying to send data as a model from an html form to

  • 0

I am trying to send data as a model from an html form to a Controller method. I am, however, unsure of how the jQuery ajax post sends such information to the Controller. The actual error I get when I submit the form is:

The resource could not be found… Requested URL: /OnCallSchedule

I know the address is correct, so I suspect that the data being passed does not match the model passed to the controller method:

[HttpPost]
public JsonResult getSchedule(DateModel dateMod)
{
    ...
    return Json(data);
}

The ajax code is:

$(function () {
    $('form').submit(function () {
        alert('@Url.Action("getSchedule")');
        var date = $('form').serialize();

        var jqxhr = $.post('@Url.Action("getSchedule")', date, function (data) {
            alert("success!");
        })
        .success(function() { alert("second success"); })
        .error(function() { alert("error"); })
        .complete(function() { alert("complete"); });

        jqxhr.complete(function() { alert("second complete"); });
    });
});

The first alert statement, listing the path to the method, successfully triggers. After that, the error message pops up, and no other alerts appear.

It should be noted that I have tried this using just about every tactic, so I suspect that I am not sending the data correctly using the serialize() command. What am I doing wrong?

It’s also likely that I am not performing the jqxhr actions correctly. The only place I could find understandable examples are in the jQuery documentation. I was originally using something like:

$.ajax({
    url: '/OnCallSchedule/getSchedule',
    type: 'POST',
    dataType: 'json',
    data: $('form').serialize(),
    contentType: 'application/json; charset=utf-8',
    success: function(data) {
        $("#dataTable").html(data);
    }
});
  • 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-06T22:41:04+00:00Added an answer on June 6, 2026 at 10:41 pm

    I figured out my problem. I am using the MVC style of forms (namely @Html.BeginForm), which was automatically calling out for a controller action. I was not successfully subverting this functionality, so the ajax code I wrote was pointless. I ended up doing away with the ajax function and @Html.BeginForm altogether, in favor of @Ajax.BeginForm. Specifically:

    @using (@Ajax.BeginForm("getSchedule",
                            "OnCallControl", 
                            new AjaxOptions{HttpMethod = "Post",
                                            InsertionMode = InsertionMode.Replace,
                                            UpdateTargetId = "data"}))
    {
        ...
    }
    

    I learned the hard way that MVC doesn’t always play nice with functionality that its framework doesn’t support.

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

Sidebar

Related Questions

Actually I am trying to send data from jQuery to Spring controller and in
I'm trying to send data to the Controller from the View. I have a
I'm trying to send post data between pages with Post. Not a form -
i am trying to send multiple data using j query $.ajax method to my
I am trying to send data from PHP Client to Python Server. CLIENT <?php
I am trying to send data from an activity to service via intents. This
I am currently trying to send some data from and Android application to a
I'm trying to make updates to a model using Ajax/POST. I'd like to be
I'm trying to use Rails(2)'s to_json model serializing mechanism to emit some data from
I am trying to send a model as json. The model has binary data

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.