weixin_33701251 2016-06-13 19:10 采纳率: 0%
浏览 28

jQuery中的AJAX获取功能

Help me get a text field number then make a multiplication table of the number. using AJAX in jQuery. The below script is not working for me

$(document).ready(function(){
    var numValue = $("#num").val();
    $.get("path.php", {number: numValue} , function(data){
        $("#result").html(data);
    });
 });
  • 写回答

1条回答 默认 最新

  • weixin_33701251 2016-06-13 19:20
    关注

    you are trying to get a html element value then request the server then display the fetched details to your browser below is the whole example and i have included the script in it

    <!DOCTYPE html>
    
    <html lang="en">
    
    <head>
    
      <meta charset="utf-8">
    
      <title>AJAX</title>
    
      <script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
    
      <script type="text/javascript">
    
            $(document).ready(function(){
    
                  $("button").click(function(){
    
                // Get value from input element on the page
                   var numValue = $("#num").val();
    
                // Send the input data to the server using get
                  $.get("../php/create-table.php", {number: numValue} , function(data){
    
               // Display the returned data in browser
                  $("#result").html(data);
    
        });
    
      });
    
    });
    
    </script>
    
    </head>
    
    <body>
    
       <label>A number Between 10 t0 100 <input type="text" id="num"></label>
    
        <button type="button">Generate Table</button>
    
             <div id="result"></div>
    
         </body>
    
       </html>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿