S. Tate
S. Tate

Reputation: 11

404 Error On Ajax Post

I am new at web dev and am trying to get a post method to successfully run.

Here is my ajax call:

    $.ajax({
        type: "POST",
        url: '/Controllers/AddPropertyData',
        contentType: "application/json; charset=utf-8",
        data: null, //Maps the controller params
        dataType: "json",
        success: function() { alert('Success'); }
    });

I have also tried this call with the url as: "/AddPropertyData". Here is the post method I am trying to call which currently does nothing but return the view (removed all functionality for testing).

    [HttpPost]
    public ActionResult AddPropertyData(){

        return View();
    }

Everything I've tried has resulted in a 404 error. I am using the new Visual Studio for Mac and I've noticed that some of the config files have weird default values. I have changed my Startup.cs file as such:

        app.MapHttpRoute(routes =>
        {
            routes.MapRoute(
                name: "default",
                template: "{controller=Home}/{action=Index}/{id?}");
        });

It used to be app.UseMVC or something along those lines.

Any help would be greatly appreciated! Thanks.

Upvotes: 0

Views: 1081

Answers (1)

Frank Odoom
Frank Odoom

Reputation: 1566

You are getting an error 404 which according to HTTP means Not Found. You probably on the wrong route which doesn't map to any resource.

Upvotes: 1

Related Questions