dpea85385 2013-08-18 10:19
浏览 70

简单的AJAX用于传递jquery的datepicker变量

Im beginner in JS & AJAX so please bear with me.

I use codeigniter framework in this project. I want to create a datepicker and passing its value through AJAX. This is the script :

<script>
    $(function() {
        $( "#datepicker" ).datepicker({
          changeMonth: true,
          changeYear: true
        });

        $("#btn_insert").click(function() {
            var url = "<?php echo base_url();?>" + "index.php/backend/umat";

            $.ajax({
                type: 'POST',
                url: url,
                dataType: "json",
                data: $('#my_form').serialize(),
                success: function(data) {
                    alert(data);
                },
                error: function(xhr, status, error) {
                    /*var err = eval("(" + xhr.responseText + ")");
                    alert(err.Message);*/
                    alert("a");
                }
            });
        });

    });
</script>

The datepicker is already shown & working fine. However the AJAX is still not working. When i tried to alert the error (the one i commented in code), it doesnt alert anything. So i tried to alert("a"); and yes, "a" is alerted so theres something wrong in the AJAX. The data is never alerted which means it never success.

Theres no error in the console. Im using chrome browser.

Any help is appreciated and please just ask me if you need something. Thanks :D

  • 写回答

1条回答 默认 最新

  • doulangyu9636 2013-08-18 14:03
    关注

    Can you try writing this url in you browser http://mysite.com/index.php/backend/umat and show information? check your htaccess perhaps index.php is delete

    评论

报告相同问题?

悬赏问题

  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探