简体   繁体   English

jQuery Ajax URl问题

[英]jquery Ajax URl issue

I have looked around quite a bit and it seems absolute urls is the way to go here. 我到处逛逛了很多,看来绝对URL才是正确的选择。 I have no problem in chrome but firefox and IE IE still wants to redirect fully to the wrong page. 我在chrome中没有问题,但是firefox和IE IE仍然希望完全重定向到错误的页面。

my states: 我的状态:

<script type="text/javascript">
    $(function() {

        $('#page_submit').click(function () {

            event.preventDefault();

            $('.standard span').hide();

            var pw = $("input#pw").val();  
            if (pw == "") {
                $("span#pw_err").show();
                $("input#pw").focus();  
                return false;  
            }

            var pw2 = $("input#pw2").val();  
            if (pw2 == "") {
                $("span#pw2_err").show();
                $("input#pw2").focus();  
                return false;  
            }

            if (pw != pw2) {
                $("span#match_err").show();
                $("input#pw2").focus();  
                return false;  
            }           

            var data = 'pw=' + pw + '&pw2=' + pw2;

            $('.standard input').attr('disabled','true');
            $('.loading').show();

            $.ajax({
                url: "/members/includes/change.php",
                type: "GET",
                data: data,
                cache: false,
                success: function (html) {
                    //hide the form
                    $('#pw_form').fadeOut('slow');

                    //display results
                    $('#pw_form_result').fadeIn('slow');
                    $("#pw_form_result").html(html);
                }       
            });

            return false;
        });     
    });
</script>

the structure of the file I am trying to access is: 我尝试访问的文件的结构是:

www.site.com/members/includes/change.php www.site.com/members/includes/change.php

Not sure what the cause is really. 不知道是什么原因。 I know the jquery initiator is working because i can summon alert calls to and from the function itself. 我知道jquery发起程序正在工作,因为我可以召唤函数本身的警报调用。

edit 编辑

after commenting out 评论后

event.preventDefault(); event.preventDefault();

it seems to function right? 它似乎起作用了吗? everything I had read before said this was a necessary piece however. 我之前阅读的所有内容都说这是必要的。

This line 这条线

$('#page_submit').click(function () {

should be 应该

$('#page_submit').click(function (event) {

so this code 所以这段代码

event.preventDefault();

can take effect. 可以生效。

And the 'return false;' 还有“返回假”; is unneccesarry. 毫不费力。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM