Id & textarea text how ever the only item that is passed to the controller is the Id
in the debugger (chrome client side) the data is fine not it is not posted to controller with the Error
I hope my question/problem is clear , Thanks
result is not defined"
code :
//the controller
[HttpPost]
public IActionResult _AskQ(QAViewModel Vm )
{
...
//the razor view //The Call button to boostrap model <button class="btnShowModal btn btn-primary btnWhiteSpace" id="@item.Id" type="button" value="@item.Id" > @item.Id <i class="fas fa-info-circle" aria-hidden="true"></i> </button> Note : the button is not in the form (it need to stay that way)
//Open boostrap pop model
$(document).ready(function() {
$(".btnShowModal").click(function() {
$("#loginModal").modal('show');
});
});
//Post to controller
$(function() {
$(".btnShowModal").click(function() {
var id = $(this).attr("id");//Get id from the button
console.log(id);//Results OK
$(".button4").click(function() {
url = '@Url.Action("_AskQ", "Bid")';
var value = $.trim($("textarea").val());
if (value === "") {
alert(value);
}
data = {//message: "data is not defined"
Id: id,//Results value OK
value: value //Results value OK
};
$.post(url,
data,
function(result) {// result =message: "result is not defined"
var id = id;
// $(id + value).html(result);()
$(id).html(result);
});
});
}
);
});
</script>
Member
131 Points
321 Posts
posting to controller with Js not passing all data
Mar 26, 2019 02:44 PM|john_mm|LINK
Hello,
im trying to post 2 values to controller using js
Id & textarea text how ever the only item that is passed to the controller is the Id
in the debugger (chrome client side) the data is fine not it is not posted to controller with the Error
I hope my question/problem is clear , Thanks