Im new in MVC,I have problem the button cannot call Ajax function to render Action in controller.
this bellow my script button
<input type="submit" value="show" class="btn btn-success" name="submitButton" onclick="OnActionClick()" />
My Ajax
function OnActionClick() {
alert("Error when update data");
$.ajax({
type: "GET",
url: "@Url.Content("~/Report/ViewReport")",
data: {
name:'try'
},
success: function () {
alert("ok");
},
error: function () {
alert("Error when update data");
}
});
}
and here my Action in controller
public ActionResult ViewReport(string name)
{
Database db = new Database("Collections");
List<report> data = new List<report>();
data = db.Fetch<report>(@"select top 10 * from SampleTbl where name = @0",new object[]{name});
return View(data);
}