Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to reload View after calling JQuery to do action and display message
    text
    copied!<p>I'm trying to figure out a way to reload the table, after each button action. I was thinking of reloading the page, but I don't know how I would reload the page, then print a message returned from the WebService function into the div.</p> <p>CSHTML code:</p> <pre><code>@model Namespace.Models.ItemModel &lt;div id="deleted" /&gt; &lt;input text id="curSelId" /&gt; &lt;input text id="curSelObj" /&gt; &lt;input text id="curSelfObjId" /&gt; &lt;table&gt; &lt;tbody&gt; @foreach (var item in Model.myDeleted) { &lt;tr id="@item.DeletedId" value="@item.DeletedId"&gt; &lt;td&gt;@item.Timestamp&lt;/td&gt; &lt;td class="type"&gt;@item.Type&lt;/td&gt; &lt;td class="typeid"&gt;@item.TypeId&lt;/td&gt; &lt;/tr&gt; } &lt;/tbody&gt; &lt;/table&gt; </code></pre> <p>JQuery code:</p> <pre><code>function Undo() { $.ajax({ type: "POST", url: "@Url.Content("~/webservices/retrieve.asmx/Undo")", data: "{'index': '" + $('[id$=curSelId]').val() + "'," + "'type': '" + $('[id$=curSelObj]').val() + "'," + " 'typeId': '" + $('[id$=curSelObjId]').val() + "'}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { //http://encosia.com/2009/06/29/never-worry-about-asp-net-ajaxs-d-again/ if (msg.hasOwnProperty("d")) { // Leave the .d behind and pass the rest of // the JSON object forward. var obj = msg.d; $("#deleted").html(obj); } else { // No .d; no transformation necessary. AjaxSucceeded(msg, dropdown, hidden); } } , error: AjaxFailed }); } </code></pre> <p>Edited: Added input fields.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload