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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:44:54+00:00 2026-06-12T16:44:54+00:00

I am currently working through Pluralsight training for WebAPI and am running into some

  • 0

I am currently working through Pluralsight training for WebAPI and am running into some issues (downloading the examples didn’t help as they don’t work either – the course was created off of the Beta and I’m using the final version with .Net 4.5). I’ve created a very simple view with the following HTML:

<form onsubmit="return submitCourse();">
     <input type="text" name="name" id="name" />
     <input type="submit" value="Create Course" />
</form>
<h1 id="msg"></h1>
<script>

//1: have form - get values from form - send to API as json
//2: use form values

function submitCourse() {

    //$.ajax({
    //    url: '/api/courses',
    //    type: 'POST',
    //    dataType: 'json'
    //});

    $.ajax({
        url: '/api/courses/',
        type: 'POST',
        dataType: 'json',            
        success: function (newCourse) {
            var msg = 'New course id = ' + newCourse.id;
            $('#msg').text(msg);
        }
    });

    return false;
}

</script>

What is supposed to happen is when the form goes to submit, the script runs first and the form data is transmitted for me via an AJAX call. The problem I’m encountering is when the Post method gets hit in my controller, the “newCourse” parameter is always null:

    public Course Post(Course newCourse)
    {
        newCourse.id = _courses.Count;
        _courses.Add(newCourse);

        //TODO : return 201
        return newCourse;
    }

Digging through various tools, I found the script above doesn’t seem to be sending the data at all (content length is 0), however I can’t seem to figure out why (new to WebAPI and jQuery’s $.ajax() call). I’ve tried explicitly setting the body of the call to the form values using the “data” option inside the $.ajax() call (like this: data: { ‘name’ : $(‘#name’).text() }), but that didn’t do much either. The content length seemed to change (to 5, not sure why) but the values still aren’t being deserialized.

Any tips? I’m too new to both of these technologies to know where to start.

  • 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-12T16:44:56+00:00Added an answer on June 12, 2026 at 4:44 pm

    You need to post the data to the API using data option inside $.ajax(). You can use data: $(“#CourseForm”).serialize(), if you give the id ‘CourseForm’ to the form and make sure the name of the input fields inside the form matches the property names of Course, for binding to work.

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

Sidebar

Related Questions

I am currently working through Michael Hartl's Rails Tutorial while experimenting with some other
I'm currently working through some exercises in a c++ book, which uses text based
So I'm currently working on a Berkeley database through C, and I ran into
I'm currently battling through some memory leaks and having some serious trouble working out
I'm currently working through Hartl's tutorial, struggling to deploy to heroku. Running OSX 10.8.1.
I'm currently working through Apress's Beginning iPhone 3 Development. A standard they use in
I'm currently working through an assignment that deals with Big-O and running times. I
I'm currently working through some concepts in a computer-science textbook. Linear algebra is heavily
I'm attempting to do a release of some software and am currently working through
I've been working through the Stanford iPhone Coding course and currently hooking into the

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.