I have some requirement like, i need to create a jquery grid.I created the JQgrid, for that JQgrid i need to get some dynamic values from the controller method That method may return int or string (not an another view).When i am calling the controller method using @Url.Action("method", "controller").I am not getting value and that code part is not executing.
function setrownumJQ() {
var rownum = 0;
rownum = '@Url.Action("method", "controller")';
return rownum;
}
Method in controller:
int setRowNum()
{
var r = 4;
return r;
}
Note: This method will return a int value.
You just told the URL, but you not called it.. solution is use $.ajax of jquery and call the action methods
function setrownumJQ() {
var rownum = 0;
var url = '@Url.Action("method", "controller")';
$.ajax({
url: url
}).done(function (data) {
rownum = data
});
return rownum;
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments