weixin_33725239 2016-06-10 09:24 采纳率: 0%
浏览 24

国家乡村城市的Ajax

Can anyone tell me why is it used and what will it produce in brief $(this).val(); also explain var dataString = 'state_id='+ id;

Here is the full code

$(document).ready(function(){     

  $(".state").change(function(){

    var id=$(this).val();
    var dataString = 'state_id='+ id;

    $.ajax({
      type: "POST",
      url: "city_names.php",
      data: dataString,
      cache: false,
      success: function(html)
      {           
        $(".city").html(html);
      } 

    });
  });

});

Thanks in advance.

  • 写回答

6条回答 默认 最新

  • csdn产品小助手 2016-06-10 09:27
    关注

    This script will get list of all cities from state name/id:

    $(document).ready(function()
    {
      $(".state").change(function() // as state change, ajax will be called along with passing state value
      { 
        var id=$(this).val(); // it will contain the selected state value
        var dataString = 'state_id='+ id; // it will bind state value as post data to ajax
        $.ajax
        ({
          type: "POST",
          url: "city_names.php", // this file will find list of all city names from state name
          data: dataString, // it will pass parameters (state name)
          cache: false,
          success: function(html)
          {
    
            $(".city").html(html); // this will set list of cities in city list
          } 
    
        });
      });
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 is not in the mmseg::model registry。报错,模型注册表找不到自定义模块。
  • ¥15 安装quartus II18.1时弹出此error,怎么解决?
  • ¥15 keil官网下载psn序列号在哪
  • ¥15 想用adb命令做一个通话软件,播放录音
  • ¥30 Pytorch深度学习服务器跑不通问题解决?
  • ¥15 部分客户订单定位有误的问题
  • ¥15 如何在maya程序中利用python编写领子和褶裥的模型的方法
  • ¥15 Bug traq 数据包 大概什么价
  • ¥15 在anaconda上pytorch和paddle paddle下载报错
  • ¥25 自动填写QQ腾讯文档收集表