即時通訊新的MVC中,我有問題的按鈕無法調用Ajax功能渲染控制器中的操作。如何調用控制器的功能與Ajax時,單擊按鈕MVC
這種波紋管我的腳本按鈕
<input type="submit" value="show" class="btn btn-success" name="submitButton" onclick="OnActionClick()" />
我阿賈克斯
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");
}
});
}
,在這裏我的動作在控制器
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);
}
嘗試更改URL以'網址:「報告/ ViewReport」' –