次のようなリンクがあります。
<a href="/Customer/_EditCustomer?CustomerId=2" class="customer_details">Deneme Müşteri 2</a>
<a href="/Customer/_EditCustomer?CustomerId=3" class="customer_details">Deneme Müşteri 2</a>
私は次のようなjqueryajax投稿を使用したいと思います:
$(".customer_details").click(function () {
$.ajax({
url: $(this).attr("href"),
type: 'POST',
beforeSend: function () {
},
complete: function () {
},
success: function (result) {
$("#customer_operations_container").html(result);
},
error: function (result) {
alert("Hata!");
}
}); //end ajax
});
またはこれ:
$(".customer_details").click(function () {
$("#customer_operations_container").load($(this).attr("href"));
});
そしてアクションメソッド
public ActionResult _EditCustomer(int CustomerId)
{
// get customer from db by customer id.
return PartialView(customer);
}
しかし、私は自分がやりたかったことをすることができません。クリックしてリンクすると、PartialViewが読み込まれません。親なしで新しいページとして開いています。Prevent.Defaultを試しましたが、結果は同じです。
どうすればpartialViewをdivにロードできますか?
注:このようなリンクを使用する<a href="#">
と、機能します。
ありがとう。