The following configuration works – it loads the Edit view into a div:
jQuery:
$("#mydiv").load(
"/Riders/Edit",
{ riderId: 123 },
function (data) { }
);
RidersController:
Function Edit(ByVal riderId As Integer) As ActionResult
Return View(_db.Riders.Single(Function(x) x.rider_id = riderId))
End Function
But when I add an HttpPost to the controller for Edit, I get an error:
<HttpPost()>
Function Edit(ByVal model As Rider) As ActionResult
'code...
End Function
Error:
POST http://localhost:4693/Riders/Edit 500 (Internal Server Error)
Now why would I be getting a POST error on a load? I’m sure I’m just missing something in my setup, but I’m not seeing it yet.
You are passing parameters using GET method, so it never finds your controller action if you specify it to be POST. From this link: http://net.tutsplus.com/tutorials/javascript-ajax/5-ways-to-make-ajax-calls-with-jquery/
That would be your solution.