發表文章

目前顯示的是有「Ajax」標籤的文章

[電繪]:Rattus rattus-黑鼠

圖片
  In some eras, rats represented the plague and were despised creatures, but in my eyes, humans and rats are no different. -- 在某些時代裡,老鼠代表著瘟疫,是人們唾棄的生物,然而在我眼裡,人與老鼠並無不同。

[Ajax]Return-Partial-View-as-JSON

圖片
 需求: 有時候使用Ajax有return PartialView的需求,但卻又只能傳送Json,不能return PartialView,這時候就只能把想回傳的view 轉成字串了。 實作: Index: 我們簡單寫一個頁面,裡面有一個button,並寫一個click事件,在按下之後會在TOP與BOTTOM div之前回傳我們所想加入的view。 <div>     <button onclick="TestBtn()">回傳patrialView</button> </div> <div>TOP</div> <div id="PartialDiv"></div> <div>BOTTOM</div> @Html.Hidden("TestViewUrl",Url.Action("TestViewToString", "Home")) @section scripts {     <script>         function TestBtn() {             $.ajax({                 url: $('#TestViewUrl').val(),                 type: "POST",                 success: function (e) {                     $('#PartialDiv').html(e.TestView);                 }, ...