Jquery .Ajax error when trying to POST data in ASP.NET MVC

Posted by GB on Stack Overflow See other posts from Stack Overflow or by GB
Published on 2010-04-09T20:32:10Z Indexed on 2010/04/09 20:53 UTC
Read the original article Hit count: 262

Filed under:
|
|
|

I am unable to access an action in my controller using .ajax. The code works on my development machine but as soon as I place it on the server it gives the error 401 Unauthorized. Here is a snippet of the code in the .aspx file...

var encoded = $.toJSON(courseItem);


    $.ajax({
        url: '<%= Url.Action("ViewCourseByID", "Home") %>/',
        type: "POST",                        
        dataType: 'json',
        data: encoded,
        //contentType: "application/json; charset=utf-8",
        success: function(result) {

Update: The only time this doesn't work is when I pass json data to the Ajax call, it works fine with HTML data.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about asp.net-mvc