だから私はいくつかのアクションリンクとjavascriptメソッドを含む私のビューを持っています、私が欲しいのはアクションリンクで私のスクリプトを呼び出すことです、これは私のスクリプトです:
function deleteSubscriber(id)
{
var url = '/Subscribers/Delete/' + id;
$.ajax({
type: "delete",
url: url,
data: {},
datatype: 'json',
success: function (data) { alert(id); },
});
}
これは私のアクションリンクです:
@Html.ActionLink("Delete", "Delete", new { id=//here i want to put my script },new { @class = "delete-logo" })
これが私の行動です:
[HttpDelete,ActionName("delete")]
public ActionResult Delete(string id)
{
try
{
IEnumerable<Subscribe> list = from s in dbcontext.Subscribes select s;
foreach (var sb in list)
{
if (sb.cin == id)
{
dbcontext.Subscribes.Remove(sb);
}
}
dbcontext.SaveChanges();
return View("Index");
}
catch
{
return View();
}
}