First Method:
<input type=” button” name="button" id="btnadd" value="Add"
onclick="location.href='@Url.Action("ActionResultName",
"ControllerName")'" >
Second Method:
<script>
$(document).ready(function(){
$("button").click(function(){
var Url='@Url.Action("ActionResultName", "ControllerName")';
$.post(Url, function(data,status){
alert("Data: " + data + "\nStatus: " + status);
});
});
});
</script>
Third Method
<script type="text/javascript">
$(function () {
$('.button1').click(function () {
$.ajax({
type: "POST",
data: {},
url: '@Url.Action("MyAction", "MyController")',
dataTyp: "html",
success: function (result) {
// whatever I did here on success
}
});
});
});
</script>
Fourth Method:
<script>
$(document).ready(function(){
$("button").click(function(){
Var Url='@Url.Action("ActionResultName", "ControllerName")';
$.getJSON(Url,
function(result){
$.each(result, function(i, field){
$("div").append(field + " ");
});
});
});
});
</script>
No comments:
Post a Comment