I have bellow action in my controller:
public ActionResult ShowContactTel(string tel)
{
return PartialView("ContactInfoView", tel);
}
And I call above action by JavaScript like this: (It is fired by clicking on a button)
function ShowTel(){
var e="@Model.TelShow";
$.get("ViewProfile/ShowContactTel", e).then(
function (r) {
$('#divTel').innerHTML = r;
});
}
But input argument of action receives null value (by setting break-point) and so return undesirable output.
Remark 1:
I tried bellow code for ShowTel() function but result not changed:
var str = "@Model.TelShow";
$.ajax({
type: 'GET',
url: '@Url.Content("~/ViewProfile/ShowContactTel")',
data: str,
success: function (dd) {
$('#divTel').innerHTML = dd;
}
});
And
var str = "@Model.TelShow";
$.ajax({
url: "ViewProfile/ShowContactTel",
type: 'GET',
data: str
}).then(function (r) {
$('#divTel').innerHTML = r;
});
I also tried type: 'POST' but it not working too.
Remark 2:
Using debugger command in ShowTel() function, I see @Model.TelShow has true value.
What is the problem?