asp.net mvc - jQuery Ajax call for buttons on a list -


I have data in a view from an asp.net mvc application. This is a list of stocks and I have two images (one plus and one zero) at the end of each row which will allow me to increase or decrease the amount of stock. It works fine with a call for MVC action currently, but since the list is long, I have to use jQuery and AJAX without a refresh on the phone. I want to do this with controversial JavaScript so that my images do not have onclick handlers. Since I'm just starting with jQuery, I do not know how I can iterate all the images and add functions. These form images are with tags like they are standing:

  & lt; Td> & Lt;% (Html.BeginForm ("Increase", "Stock", New {id = Item. Stokee ID})) {%> & Lt; Input type = "image" src = "/ content / images / bullet_add" style = "margin-left: 20px;" / & Gt; & Lt;%}% & gt; & Lt; / TD & gt; & Lt; Td> Use of & lt;% (Html.BeginForm ("decrease", "stock", new {id = item.stock id})) {%> & Lt; Input type = "image" src = "/ content / images / bullet_delite.png" style = "margin-left: 10px;" / & Gt; & Lt;%}% & gt; & Lt; / TD & gt;  

Can anyone help me a bit?

This is undiscovered, but hopefully this is going to you in the right direction. If you can provide more information based on the above comment, then I will update my answer.

  $ (document) .ready (function () {// This is all & lt; input type = 'image' & gt; control for all forms on the page. Focus on the formats / maybe the ID of a containing div, etc. $ ("[input form [input type = image]"). Click (function () {// image clicked on image $ var $ image = $ (This); // $ form is now the jQuery object variable, which is now a jQuery object variable that has the parent & lt; form & gt; clicked image var $ form = $ image.parent (); // stockId now Id of a variable reference Refers, assuming that this is a stock ID which we have var stock head head head Imperial = $ form.attr ("id"); // Perhaps there is a better way of doing this, but know that we are up or down I want to go, I have checked the source attribute of the input type = 'image' & gt; control // if the image is added to the URL, the direction is added, else it is del var direction = $ Image.attr ("src"). Is there ("add")? "Add": "del"; // add, del shiftStock (stock id, dd) Call a function to handle; }); }); // A javascript function that accepts stock ID and in which direction we pass shiftStock (stock ID, direction) {// do an AJAX call, use jQuery, pass our stock ID and direction, But another XML returns data type, but it can easily be a post with json, $ $ .exe (type: "GET", url: "webserviceurl ??", data type: "XML", data: " Stock id = "+ stockID +" and instructions = "+ direction, success: function (ex SML) {// If any UI updates, such as new stock numbers etc, have to be returned to take precautions to be analyzed XM? Warning (xml);}, error: function (XML, error, status) {warning ( Error);}); }  

Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -