社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
私信  •  关注

jpneey

jpneey 最近创建的主题
jpneey 最近回复了
4 年前
回复了 jpneey 创建的主题 » 从用户输入号码到更新可用数量的jquery ajax调用

您应该监听输入值的变化,然后运行ajax调用。然后在成功后,呈现后端的响应

<table id="myTable">
        <tr>
        <th>Product Line</th>
        <th >Quantity</th>
        <th>Available Quantity</th>
        </tr>
        <tr>
            <td id="product-number">test product <br> 56789</td>
            <td><input type="number" id="product-quantity" name="quantity" min="1" max="999"></td>
            <td id="available-quantity"></td>
        </tr>  
</table>
$(function(){
    $('#product-quantity').on('keyup', function() {
       // if input value is changed, run the ajax call here
       $.ajax({
          .... <- fill in all required details here such as url, method, etc.
          success: function (data) {
            // then on ajax success, display the results from your backend
            $('#available-quantity').html(data)
          }
       })
    })
})

关于如何通过jquery调用ajax的参考: https://api.jquery.com/jquery.ajax/