javascript - Passing data from jQueryUI dialog form to controller -
i'm new asp.net/javascript , i'm having little trouble implementation of simple crud operations using jqueryui dialog form. code:
<button class="update" id="@model.id">update</button> <div id="dialog-form" title="update"> <form> <fieldset> <input type="text" name="state" id="state"> <input type="text" name="note" id="note"> <input type="submit"> </fieldset> </form> </div> <script> $(function() { var dialog, state = $("#state"), note = $("#note"), id = this.id, //?? dialog = $("#dialog-form").dialog({ autoopen: false, height: 400, width: 350, modal: true, buttons: { "ok": function() { $.ajax({ type: "post", url: "@url.action("update","ticket")", data: { id: id, state: state, note: note }, cache: false, datatype: "json", success: function(data) { $("#dialog").dialog("close"); } }); }, "cancel": function() { $(this).dialog("close"); } } }); $(".update").button().on("click", function() { dialog.dialog("open"); }); }); </script>
finally update
action in ticketcontroller
:
public actionresult update(string id, string state, string note) { //do stuff }
however nothing happens , doesn't action. appreciated
change data
below need pass value rather object using .val()
state = $("#state").val(), note = $("#note").val(), id = "pass wants" data: { 'id':id,'state':state,'note':note },
decorate action method [httppost]
[httppost] public actionresult update(string id, string state, string note) { }
Comments
Post a Comment