weixin_33711647 2013-12-19 20:42 采纳率: 0%
浏览 9

Ajax发布没有被点击

I am using codeigniter where i put the post backend coding under models/add_subscriber.php but the code not being hit. Any idea?

form.onsubmit = function(event) {
            validate();
            if (!isValid) {
                revalidateOnChange();
                return false;
            }
            var email = $("#signup_email").val();
            dataString = 'email=' + email;
            $.ajax(
                    {
                        type: "POST",
                        url: '<?php echo base_url()?>models/add_subscriber.php',
                        data: dataString,
                        success: function(response) {
                            alert(response);
                        },
                        error: function(xhr, textStatus, error) {

                        }
                    });
               return;

        };
  • 写回答

2条回答 默认 最新

  • Memor.の 2013-12-20 04:18
    关注

    try to figure out step by step,

    1. Your request is working check in firebug or chrome developer tool net panel may be javascript error there.
    2. hit directly the url see the url is valid view source of the javascript and copy the ajax url and paste it to address bar and see whether your url is valid.
    3. if url is ok and ajax is working and the response isn't 404 than check your controller, htaccess etc.

    Suggestion

    if you want a URL access to a resource (such as css, js, image), use base_url(), otherwise, site_url() is better. source

    评论

报告相同问题?