AJAX Post From Button Click On Custom MVC Widget Returns 404

Posted by Community Admin on 04-Aug-2018 15:46

AJAX Post From Button Click On Custom MVC Widget Returns 404

All Replies

Posted by Community Admin on 17-Jun-2015 00:00

I have a custom MVC Widget contained in an external class assembly that returns a 404 error when a button click calls an ajax post function calling a method in the controller.

The initial call to Index works, I have no custom routing set up.

The button click calls a javascript function: 

     function saveRequest()

        //create object
        var obj =
            FirstName: $("#firstname").val()
            ,LastName: $("#lastname").val()
            , Email: $("#email").val()
            , UserName: $("#email").val()
            , Password: $("#password").val()
            , IsApproved: false
        ;

        //pass it to controller
        $.ajax(
            type: "POST",
            dataType: "json",
            contentType: "application/json; charset=utf-8",
            url: "accountrequestwidget/saverequest",
            data: JSON.stringify( request: obj ),
            success: function (response)
                ...
            ,
            error: function (response)
               ...
           
        ).done(function ()
             ...
        );
   

And that calls this controller method:

        public virtual JsonResult SaveRequest(AccountRequestWidgetModel request)
       
             ...
             return Json(new status = "success", msg = "Request Successfully Sent" );
       

In the browser- I can directly type in the /page-name/method (localhost/sitefinitywebapp/account-request/saverequest) and get the method to run-  but putting that into the ajax url (e.g. page name/method)  still returns a 404.

 How do I make Ajax calls to the custom widget's controller methods?

 Thank you!
Kevin Howell

Posted by Community Admin on 31-Jan-2016 00:00

Dude, can you fix this?

I have the same error.

 

Regards

This thread is closed