AJAX Post From Button Click On Custom MVC Widget Returns 404
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
Dude, can you fix this?
I have the same error.
Regards