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

  @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; }   

Ajax

  $ ("# 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"}}}};   

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 .

  & 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 () "/>   

button -

  Submit Public Execution Submit (String Name) { Jason (new person () {name = name + "This is me"});}   

And the only action A simple purpose of Ti (I used it for the purpose of example).

  public class person {public string name {receipt; set;}}   

Now when you click on the button -

Enter the image details here

If you want to perform a GET operation, then the JQuery code should be -

  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);}});   

person () {Name = id + "its me"}, JasonSeverest Behavior Alowet); }

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -