Reputation: 2129
I am new to both MVC and JQuery, but this should not really be that difficult. When I call the function, nothing happens. I put an alert box in the function, and I can see that the function is called.
I found this, but it did not help me: Calling ASP.NET MVC Action Methods from JavaScript
This is my script:
<script type="text/javascript">
function oKButtonPressed(){
jQuery.ajax({
type: "POST",
url: "@Url.Action("MessageToPatient", "StartScreen")"
});
};
</script>
MessageToPatient
is the name of the action method. StartScreen
is the name of the controller.
Can you see something obvious I'm missing? Otherwise, it might be something with my MVC code.
Upvotes: 0
Views: 1180
Reputation: 5366
You are Getting/posting to an action using jQuery.Ajax.
You can return data to this jQuery, but an MVC view will not be rendered as if it was just a normal request. You have to process the returned data in some way.
See this for example: http://www.itorian.com/2013/02/jquery-ajax-get-and-post-calls-to.html?m=1
Upvotes: 2