douchen5971 2012-12-22 05:37
浏览 43
已采纳

用jquery和ajax根据州改变城市

I want to know difference between $.ajax and $.post in jquery. I search it but not getting clearification. Actually I am having drop down of states and cities and I am changing cities when states changes with jquery $.post. Here is my code of jquery

$.post('includes/change_cities.php', { 'state_id': state_id },
        function( data ) {
        var content = $( data );
        $( "#cities" ).empty().append( content );
        }
        );

My Problem is when states changes for the first time it takes too much time to change cities about 4 to 5 seconds but after first time it becomes normal means changes cities without taking any time. So Is there any problem in my code or should I use any other method for this.

-Thanks

  • 写回答

3条回答 默认 最新

  • dongli8862 2012-12-22 05:44
    关注

    The performance Depends on your code and sql implementation.
    $.post is subset of $.ajax in tersm of functionality.

    $.ajax({
    type: 'POST',
    url: 'ajax/test.html',
    data: data,
    success: function(data){
    $('.result').html(data)
    },
    });

    is Equivalent to

    $.post('ajax/test.html', function(data) {
    $('.result').html(data);
    });

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?