jquery - Use ajax to call ActionResult with value from text box. -
User update Given quantity is only a field, click on the Accept button to update the user Does the number entered in the textbox and Ajax via ShoeOrderItem Ajax I would only like to call ActionResult with the value entered by the user when they click Craig Button AcceptItem. Follow this solution - Say that you have the following form, give the appropriate ID for the input field and notice that I have a post operation . button - And the only action A simple purpose of Ti (I used it for the purpose of example). Now when you click on the button - If you want to perform a GET operation, then the JQuery code should be - person () {Name = id + "its me"}, JasonSeverest Behavior Alowet); }
@for (int i = 0; i Model; ShoeorderItemList.Count (); i ++) {& lt; Tr & gt; & Lt; Td class = "text-center" & gt; @ Html.HiddenFor (model = & gt; model.share item list [i] .shawyer idam id) @html. DisplayFor (Model = & Model; Shower Eatmail [i]. Shawyer Eatam Id) & lt; / Td> & Lt; Td class = "text-center" & gt; @html DisplayFlier (model = & gt; model. Show eartem list [i] .linite total) & lt; / Td> & Lt; Td class = "text-center" & gt; @html DisplayFlier (model = & gt; model. Show etymic list [i]. Souce size) & lt; / Td> & Lt; Td class = "text-center" & gt; @html DisplayFor (Model = & Model; Shows Eatam List [i] .su ManningCost) & lt; / Td> & Lt; Td class = "text-center" & gt; @html DisplayFlier (model = & gt; model. Shower item list [i].); / Td> & Lt; Td class = "text-center" & gt; @html DisplayFlier (model = & gt; model. Shower item list [i] .Quantitining) & lt; / Td> & Lt; TD & gt; @ (HTML) Bootstrap (). Text Box (M => m.QuantityDelivered). Placeholder ("Quantity Delivered"). Prefix ("#"). Attachments (Html.Bootstrap (.) Button (). ("Accept") .id. ("AcceptItem"))) & lt; / Td> & Lt; / TR & gt; }
$ ("# AcceptItem"). Click (function () {var quatntity = @ html.raw (json.Encode (model)). AJX ({url: "Schuoder / CreateShow Delivery", Type: "GET", Data: {shoeOrderItemId: shoeOrderItemId [i I want to call ActionResult with the value entered by the user, when they click on the button AcceptItem, the quantity is delivited: quantity, datatype: "html"}}}};
& lt; script src = "~ / scripts / jquery-1.10.2.min.js" & gt; & lt; / script & gt; script & Gt; function submitForm () {jQuery.ajax ({type: "post", url: "@ Url.Action (" submit "), data type:" Jason ", content type:" App / Jason; Val (); Data: $ ("# Quantity"). Val ()}, Success: Function (Data) {Warning (Data Name);}, Failure: Function (errMsg) {Warning (errMsg) ;}})}} & gt; input type = "button" value = "click" onclick = " Action will be submitted upon clicking submitForm () "/>
Submit Public Execution Submit (String Name) { Jason (new person () {name = name + "This is me"});}
public class person {public string name {receipt; set;}}
jQuery.ajax ({type: get", url: "@ Url.Action ("submit") "+" / "+ $ (" # quantity "). Val (), Data type: "json", contentType: "application / json; charset = utf-8", data: "", //JSON.stringify ({name: $ ("# quantity"). Val () }), Success: function (data) {warning (data.Name);}, failure: function (ErrMsg) {warning (errMsg);}});
Comments
Post a Comment