Update span content with php response on submit
Hi,
I am really new with jQuery, I read a lot of tutorials and documentation, but still I don't get it
I have a simple HTML table:
When an amount is filled in in the text field and the button Sell is clicked, I want that the following happens:
- updateAmount.php must be run, it will or return the text error or it will return "success" + new amount.
- When it returns the text "error", that text must be shown in <span id="status"></span> and fade out after 2 seconds.
- When it returns the text "success", that text must be shown again in <span id="status"></span> and fade out after 2 seconds, BUT, it must also update the quantity with the new amount.
Anyone can redirect me in the right direction?
This is my HTML code:
- <div class="row large-centered">
- <input type="text" id="search" placeholder="Type to search..." />
- <table id="table" width="800px">
- <thead>
- <tr>
- <th>Product</th>
- <th>Quantity</th>
- <th>Location</th>
- <th>Action</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>2TB SATA Western Digital</td>
- <td><span id="prodAmount">32</span></td>
- <td>IS102</td>
- <td><input type="text" id="amount" placeholder="Amount.." /> <input type="button" value="Sell"> <span id="status"></span></td>
- </tr>
- <tr>
- <td>480GB SSD Samsung</td>
- <td><span id="prodAmount">19</span></td>
- <td>IS020</td>
- <td><input type="text" id="amount" placeholder="Amount.." /> <input type="button" value="Sell"> <span id="status"></span></td>
- </tr>
- <tr>
- <td>16GB 10600R</td>
- <td><span id="prodAmount">12</span></td>
- <td>IS100</td>
- <td><input type="text" id="amount" placeholder="Amount.." /> <input type="button" value="Sell"> <span id="status"></span></td>
- </tr>
- <tr>
- <td>8GB 8500U</td>
- <td><span id="prodAmount">3</span></td>
- <td>ISO100</td>
- <td><input type="text" id="amount" placeholder="Amount.." /> <input type="button" value="Sell"> <span id="status"></span></td>
- </tr>
- <tr>
- <td>32GB 8500U</td>
- <td><span id="prodAmount">21</span></td>
- <td>ISO100</td>
- <td><input type="text" id="amount" placeholder="Amount.." /> <input type="button" value="Sell"> <span id="status"></span></td>
- </tr>
- <tr>
- <td>4GB 8500U</td>
- <td><span id="prodAmount">4</span></td>
- <td>ISO100</td>
- <td><input type="text" id="amount" placeholder="Amount.." /> <input type="button" value="Sell"> <span id="status"></span></td>
- </tr>
- </tbody>
- </table>
- </div>